From 89209886427145b6511130735f5fd0c117bf966d Mon Sep 17 00:00:00 2001 From: til-schneider Date: Tue, 2 Feb 2016 18:18:06 +0100 Subject: [PATCH] Fixed: Scroll sync didn't work in Firefox --- src/client/js/app-edit.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/client/js/app-edit.js b/src/client/js/app-edit.js index b76f06e..a3c0f8a 100644 --- a/src/client/js/app-edit.js +++ b/src/client/js/app-edit.js @@ -124,9 +124,14 @@ // Synchronize scroll position of preview when editor is scrolled var scrollInfo = editor.getScrollInfo(), scrollFactor = scrollInfo.top / (scrollInfo.height - scrollInfo.clientHeight), - bodyElem = document.body; + docElem = document.documentElement, + bodyElem = document.body, + scrollHeight; - window.scrollTo(0, scrollFactor * (bodyElem.scrollHeight - bodyElem.clientHeight)); + // Workaround: In Chrome the body has the real scrollHeight, in Firefox the documentElement has it + scrollHeight = Math.max(docElem.scrollHeight, bodyElem.scrollHeight); + + window.scrollTo(0, scrollFactor * (scrollHeight - bodyElem.clientHeight)); } function callRpc(objectName, methodName, paramArray, done) {