1
0
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:
til-schneider
2015-12-22 21:25:59 +01:00
parent b771b39ba5
commit c0814d3445

View File

@@ -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;