diff options
author | Andrew Dolgov <[email protected]> | 2020-11-20 20:24:24 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2020-11-20 20:24:24 +0300 |
commit | 7df3df758589dde34aa49dfe20a5079e47366014 (patch) | |
tree | bcee5e62973e58a76aa9a89652bea5f95ebde65c /js | |
parent | 94e0592f456880e72a8d8114db80e2288958c638 (diff) | |
parent | 076a76af57ae2ec4e87f15b38f20e367a5225a14 (diff) |
Merge remote-tracking branch 'origin' into app-online
Diffstat (limited to 'js')
-rw-r--r-- | js/reader_iframe.js | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/js/reader_iframe.js b/js/reader_iframe.js index 80e597e..c58061e 100644 --- a/js/reader_iframe.js +++ b/js/reader_iframe.js @@ -21,13 +21,13 @@ $(document).ready(function() { Reader = parent.__get_reader(); App = parent.__get_app(); - $(window).on("doubletap", function(/* evt */) { + /*$(window).on("doubletap", function(evt) { const sel = getSelection().toString().trim(); if (sel.match(/^$/)) { Reader.toggleFullscreen(); } - }); + }); */ $(window).on("click tap", function(evt) { if (evt.button == 0) { @@ -58,19 +58,26 @@ $(document).ready(function() { } }); - $(window).on("mouseup touchend", function() { + let selectionChangeTimeout = null; + + $(document).on("selectionchange", function() { if (!App.onLine) return; - const sel = getSelection().toString().trim(); + window.clearTimeout(selectionChangeTimeout); - if (sel.match(/^[\w]+$/)) { - Reader.lookupWord(sel, function() { - if (typeof EpubeApp != "undefined") - EpubeApp.showActionBar(false); + selectionChangeTimeout = window.setTimeout(function() { + const sel = getSelection().toString().trim(); + + if (sel.match(/^[\w]+$/)) { + Reader.lookupWord(sel, function() { + if (typeof EpubeApp != "undefined") + EpubeApp.showActionBar(false); + + getSelection().removeAllRanges(); + }); + } + }, 250); - getSelection().removeAllRanges(); - }); - } }); enable_swipes(); |