Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Commit

Permalink
Disable snapping when scroll mode is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-menu-mantano committed Jun 13, 2019
1 parent 04bfce8 commit 0ed92a4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions r2-streamer-swift/Resources/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ var readium = (function() {
window.addEventListener("load", function(){ // on page load
// Notify native code that the page is loaded.
webkit.messageHandlers.didLoad.postMessage("");
window.addEventListener("orientationchange", orientationChanged);
window.addEventListener("orientationchange", function() {
orientationChanged();
snapCurrentPosition();
});
orientationChanged();
}, false);

Expand Down Expand Up @@ -37,7 +40,6 @@ var readium = (function() {

function orientationChanged() {
maxScreenX = (window.orientation === 0 || window.orientation == 180) ? screen.width : screen.height;
snapCurrentPosition();
}

function isScrollModeEnabled() {
Expand Down Expand Up @@ -122,6 +124,9 @@ var readium = (function() {
}

function snapCurrentPosition() {
if (isScrollModeEnabled()) {
return;
}
var currentOffset = window.scrollX;
var currentOffsetSnapped = snapOffset(currentOffset + 1);

Expand Down

0 comments on commit 0ed92a4

Please sign in to comment.