From 91c67aba77da85754f0f12664825c0261244a3b4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 25 Jan 2018 14:55:13 +0300 Subject: hide UI when page changes --- js/read.js | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'js/read.js') diff --git a/js/read.js b/js/read.js index 0852d0a..8b38277 100644 --- a/js/read.js +++ b/js/read.js @@ -1,13 +1,29 @@ var _store_position = 0; +function show_ui(show) { + if (show) + $(".header,.footer").fadeIn(); + else + $(".header,.footer").fadeOut(); +} + +function toggle_ui() { + if ($(".header").is(":visible")) + $(".header,.footer").fadeOut(); + else + $(".header,.footer").fadeIn(); +} + function next_page() { _store_position = 1; window.book.nextPage(); + show_ui(false); } function prev_page() { window.book.prevPage(); + show_ui(false); } function hotkey_handler(e) { @@ -25,10 +41,17 @@ function hotkey_handler(e) { // left if (e.which == 37) { - e.preventDefault();; + e.preventDefault(); prev_page(); } + // esc + if (e.which == 27) { + e.preventDefault(); + show_ui(true); + } + + } catch (e) { console.warn(e); } @@ -57,9 +80,7 @@ function init_taps() { if (event.clientX >= doc.clientWidth - margin_x) { console.log("RIGHT SIDE"); next_page(); - } - - if (event.clientX <= margin_x) { + } else if (event.clientX <= margin_x) { console.log("LEFT SIDE"); prev_page(); } -- cgit v1.2.3