diff options
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(); |