bugfix: only try to go to a line if the line actually exists

This commit is contained in:
John McLear 2021-10-02 15:08:14 +01:00
parent c361df52d2
commit 73a8d593bb

View file

@ -173,6 +173,7 @@ const loadBroadcastJS = (socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
const goToLineNumber = (lineNumber) => {
// Sets the Y scrolling of the browser to go to this line
const line = $('#innerdocbody').find(`div:nth-child(${lineNumber + 1})`);
if (line) {
const newY = $(line)[0].offsetTop;
const ecb = document.getElementById('editorcontainerbox');
// Chrome 55 - 59 bugfix
@ -181,6 +182,7 @@ const loadBroadcastJS = (socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
} else {
$('#editorcontainerbox').scrollTop(newY);
}
}
};
goToLineNumber(lineChanged);