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

Commit

Permalink
prevent undesirable page swipe
Browse files Browse the repository at this point in the history
  • Loading branch information
MurakamiShinyu committed Oct 28, 2018
1 parent a2a603a commit a61688b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/js/bindings/swipePages.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,23 @@ ko.bindingHandlers.swipePages = {
init(element, valueAccessor) {
if (supportTouchEvents && ko.unwrap(valueAccessor())) {
element.addEventListener("touchstart", (event) => {
if (event.touches.length > 1) {
return; // multi-touch is not for page swipe
}
if (window.visualViewport && window.visualViewport.scale > 1) {
return; // disable page swipe when pinch-zoomed
}
const viewportElement = document.getElementById("vivliostyle-viewer-viewport");
if (viewportElement && viewportElement.scrollWidth > viewportElement.clientWidth) {
return; // disable page swipe when horizontal scrollable
}
xStart = event.touches[0].clientX;
yStart = event.touches[0].clientY;
});
element.addEventListener("touchmove", (event) => {
if (event.touches.length > 1) {
return;
}
if (xStart !== null && yStart !== null) {
let xDiff = event.touches[0].clientX - xStart;
let yDiff = event.touches[0].clientY - yStart;
Expand Down

0 comments on commit a61688b

Please sign in to comment.