diff options
author | Andrew Dolgov <[email protected]> | 2018-07-02 12:31:52 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2018-07-02 12:31:52 +0300 |
commit | edbc49b9b7ad9dd4323db4a0e4ed0a7907871dd6 (patch) | |
tree | c15eb0dc8bacc471e20c0e5146e9dfa15307c398 /js | |
parent | a42f5887aee2560cec360845e89fe66092ec352b (diff) |
add option to keep UI when turning pages, remove terrible iframe onclick hack
Diffstat (limited to 'js')
-rw-r--r-- | js/read.js | 17 | ||||
-rw-r--r-- | js/reader.js | 21 |
2 files changed, 14 insertions, 24 deletions
@@ -72,12 +72,18 @@ function next_page() { _store_position = 1; window.book.rendition.next(); - show_ui(false); + + localforage.getItem("epube.keep-ui-visible").then(function(keep) { + if (!keep) show_ui(false); + }); } function prev_page() { window.book.rendition.prev(); - show_ui(false); + + localforage.getItem("epube.keep-ui-visible").then(function(keep) { + if (!keep) show_ui(false); + }); } function hotkey_handler(e) { @@ -121,19 +127,18 @@ $(document).ready(function() { return; var reader = $("#reader"); - var doc = document.documentElement; + var doc = $(document); var margin_side = parseInt(reader.css("left"), 10); var margin_top = parseInt(reader.css("top"), 10); var margin_bottom = parseInt(reader.css("bottom"), 10); //console.log(margin_side, margin_top, margin_bottom); - //console.log(event.clientY + " " + doc.clientHeight); - if (evt.clientY < margin_top || evt.clientY >= doc.clientHeight - margin_bottom) { + if (evt.clientY < margin_top || evt.clientY >= doc.height() - margin_bottom) { return; } - if (evt.clientX >= doc.clientWidth - margin_side) { + if (evt.clientX >= doc.width() - margin_side) { console.log("RIGHT SIDE"); next_page(); } else if (evt.clientX <= margin_side) { diff --git a/js/reader.js b/js/reader.js index ae96a26..d7eddbe 100644 --- a/js/reader.js +++ b/js/reader.js @@ -13,31 +13,16 @@ function enable_swipes() { } $(document).ready(function() { - console.log('setting taps'); - $(window).on("mouseup", function(evt) { if (evt.button == 0) { if ($(".modal").is(":visible")) return; - var reader = $("body"); - var margin_side = parseInt(reader.css("padding-left"), 10); - - //console.log(evt, evt.screenX); - - if (evt.screenX >= reader.width() - margin_side) { - console.log("iframe: RIGHT SIDE"); - parent.next_page(); - } else if (evt.screenX <= margin_side) { - console.log("iframe: LEFT SIDE"); - parent.prev_page(); + if (parent.$(".header").is(":visible")) { + parent.show_ui(false); } else { - if (parent.$(".header").is(":visible")) { - parent.show_ui(false); - } else { - parent.show_ui(true); - } + parent.show_ui(true); } } }); |