diff --git a/src/client/js/app-edit.js b/src/client/js/app-edit.js index d8de724..83e544b 100644 --- a/src/client/js/app-edit.js +++ b/src/client/js/app-edit.js @@ -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;