Feature: Timeslider follow (#4133)

When new edits come in changes are followed in the time slider.
This commit is contained in:
John McLear 2020-07-19 23:46:58 +01:00 committed by GitHub
parent a785914aa4
commit bf24063234
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 80 additions and 8 deletions

View file

@ -255,6 +255,11 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
debugLog(e);
}
var lineNumber = Changeset.opIterator(Changeset.unpack(changeset).ops).next().lines;
if($('#options-followContents').is(":checked") || $('#options-followContents').prop("checked")){
goToLineNumber(lineNumber);
}
Changeset.mutateTextLines(changeset, padContents);
padContents.currentRevision = revision;
padContents.currentTime += timeDelta * 1000;
@ -585,6 +590,14 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
receiveAuthorData(clientVars.collab_client_vars.historicalAuthorData);
return changesetLoader;
function goToLineNumber(lineNumber){
// Sets the Y scrolling of the browser to go to this line
var line = $('#innerdocbody').find("div:nth-child("+(lineNumber+1)+")");
var newY = $(line)[0].offsetTop;
let ecb = document.getElementById('editorcontainerbox');
ecb.scrollTo({top: newY, behavior: 'smooth'});
}
}
exports.loadBroadcastJS = loadBroadcastJS;