From c85acfd194987e2c3529ba1ac23540a5e61fc7b6 Mon Sep 17 00:00:00 2001 From: Kevin Jantzer Date: Sat, 9 Jul 2016 10:34:02 -0700 Subject: [PATCH 1/2] Fix audio 'scroll to element' for horizontal --- Source/Resources/Bridge.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Source/Resources/Bridge.js b/Source/Resources/Bridge.js index 363fa5908..26a023443 100755 --- a/Source/Resources/Bridge.js +++ b/Source/Resources/Bridge.js @@ -235,6 +235,18 @@ function goToEl(el) { if(elBottom > bottom || elTop < top) { document.body.scrollTop = el.offsetTop - 20 } + + /* Set scroll left in case horz scroll is activated. + we can set both scroll left and scroll top because the document will only + be able to scroll in one direction at a time. + + The following works because el.offsetTop accounts for each page turned + as if the document was scrolling vertical. We then divide by the window + height to figure out what page the element should appear on and set scroll left + to scroll to that page. + */ + var elLeft = document.body.clientWidth * Math.floor(el.offsetTop / window.innerHeight); + document.body.scrollLeft = elLeft; return el; } From 1f3a7decc085938dc6ae7d50942a3f8206c324da Mon Sep 17 00:00:00 2001 From: Kevin Jantzer Date: Sun, 10 Jul 2016 18:34:26 -0700 Subject: [PATCH 2/2] Fix audio vert scroll after change for horz --- Source/Resources/Bridge.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Resources/Bridge.js b/Source/Resources/Bridge.js index 26a023443..7305882e0 100755 --- a/Source/Resources/Bridge.js +++ b/Source/Resources/Bridge.js @@ -237,16 +237,16 @@ function goToEl(el) { } /* Set scroll left in case horz scroll is activated. - we can set both scroll left and scroll top because the document will only - be able to scroll in one direction at a time. The following works because el.offsetTop accounts for each page turned as if the document was scrolling vertical. We then divide by the window height to figure out what page the element should appear on and set scroll left to scroll to that page. */ - var elLeft = document.body.clientWidth * Math.floor(el.offsetTop / window.innerHeight); - document.body.scrollLeft = elLeft; + if( document.body.scrollTop == 0 ){ + var elLeft = document.body.clientWidth * Math.floor(el.offsetTop / window.innerHeight); + document.body.scrollLeft = elLeft; + } return el; }