From 38a03bd23b0e9e8a63cd81130cdd70a55d3f907d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 1 May 2018 17:23:08 +0300 Subject: another attempt at smarter swipe behavior --- js/reader.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'js') diff --git a/js/reader.js b/js/reader.js index 34c5e06..26705d6 100644 --- a/js/reader.js +++ b/js/reader.js @@ -1,5 +1,17 @@ 'use strict'; +function enable_swipes() { + $(window).off("swipeleft swiperight"); + + $(window).on("swipeleft", function() { + parent.book.nextPage(); + }); + + $(window).on("swiperight", function() { + parent.book.prevPage(); + }); +} + $(document).ready(function() { $(window).on("click tap", function() { if (parent.$(".header").is(":visible")) { @@ -10,5 +22,15 @@ $(document).ready(function() { parent.disable_fullscreen(); } }); + + $(window).on("touchstart", function() { + enable_swipes(); + }); + + $(window).on("mousedown", function() { + $(window).off("swipeleft swiperight"); + }); + + enable_swipes(); }); -- cgit v1.2.3