summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2018-02-26 13:16:24 +0300
committerAndrew Dolgov <[email protected]>2018-02-26 13:16:24 +0300
commitade92000ea4c7b05503211623b1672dc0c4b2ff1 (patch)
tree2c3f98cad809c67b7242892a60f090c13b6da229 /js
parentf41005d3759740b08f81877e868176fe6ffb28ca (diff)
use jquery event handler for side taps
Diffstat (limited to 'js')
-rw-r--r--js/read.js62
1 files changed, 29 insertions, 33 deletions
diff --git a/js/read.js b/js/read.js
index 82a3541..295a530 100644
--- a/js/read.js
+++ b/js/read.js
@@ -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;