diff options
-rw-r--r-- | js/read.js | 62 | ||||
-rw-r--r-- | read.html | 4 |
2 files changed, 29 insertions, 37 deletions
@@ -71,40 +71,36 @@ function hotkey_handler(e) { } } -function init_taps() { - try { - window.addEventListener("mouseup", - function(event) { - if (event.button == 0) { - - if ($(".modal").is(":visible")) - return; - - var doc = document.documentElement; - var margin_x = 64; - var margin_y_top = 48; - var margin_y_bottom = 48; - - //console.log(event.clientY + " " + doc.clientHeight); - - if (event.clientY < margin_y_top || event.clientY >= doc.clientHeight - margin_y_bottom) { - return; - } - - if (event.clientX >= doc.clientWidth - margin_x) { - console.log("RIGHT SIDE"); - next_page(); - } else if (event.clientX <= margin_x) { - console.log("LEFT SIDE"); - prev_page(); - } - } +$(document).ready(function() { + document.onkeydown = hotkey_handler; + + $(window).on("mouseup", function(evt) { + if (evt.button == 0) { + + if ($(".modal").is(":visible")) + return; + + var doc = document.documentElement; + var margin_x = 64; + var margin_y_top = 48; + var margin_y_bottom = 48; + + //console.log(event.clientY + " " + doc.clientHeight); + + if (evt.clientY < margin_y_top || evt.clientY >= doc.clientHeight - margin_y_bottom) { + return; } - ); - } catch (e) { - console.warn(e); - } -} + + if (evt.clientX >= doc.clientWidth - margin_x) { + console.log("RIGHT SIDE"); + next_page(); + } else if (evt.clientX <= margin_x) { + console.log("LEFT SIDE"); + prev_page(); + } + } + }); +}); function apply_line_height(elem) { var height = elem[elem.selectedIndex].value; @@ -362,12 +362,8 @@ $(".loading_message").html("This book is not available offline."); } } - }); - init_taps(); - document.onkeydown = hotkey_handler; - localforage.getItem("epube.enable-fullscreen").then(function(enable) { _enable_fullscreen = enable; }); |