mirror of
https://github.com/til-schneider/slim-wiki.git
synced 2025-08-05 08:07:35 +02:00
Synchronizing scroll position of preview when editor is scrolled
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
});
|
||||
|
||||
editor.on('changes', onEditorChange);
|
||||
editor.on('scroll', onEditorScroll)
|
||||
}
|
||||
|
||||
function onEditorChange() {
|
||||
@@ -49,6 +50,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
function onEditorScroll() {
|
||||
// Synchronize scroll position of preview when editor is scrolled
|
||||
var scrollInfo = editor.getScrollInfo(),
|
||||
scrollFactor = scrollInfo.top / (scrollInfo.height - scrollInfo.clientHeight),
|
||||
bodyElem = document.body;
|
||||
|
||||
window.scrollTo(0, scrollFactor * (bodyElem.scrollHeight - bodyElem.clientHeight));
|
||||
}
|
||||
|
||||
function callRpc(objectName, methodName, paramArray, done) {
|
||||
var request = new XMLHttpRequest(),
|
||||
requestJson;
|
||||
|
Reference in New Issue
Block a user