Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #86 from kjantzer/horizontal-scroll
Browse files Browse the repository at this point in the history
Fix audio 'scroll to element' for horizontal
  • Loading branch information
hebertialmeida authored Jul 11, 2016
2 parents 9436a5c + 1f3a7de commit 8cb435f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Source/Resources/Bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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.
*/
if( document.body.scrollTop == 0 ){
var elLeft = document.body.clientWidth * Math.floor(el.offsetTop / window.innerHeight);
document.body.scrollLeft = elLeft;
}

return el;
}
Expand Down

0 comments on commit 8cb435f

Please sign in to comment.