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

Fix audio 'scroll to element' for horizontal #86

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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