diff options
author | siikamiika <siikamiika@users.noreply.github.com> | 2019-11-03 18:56:22 +0200 |
---|---|---|
committer | siikamiika <siikamiika@users.noreply.github.com> | 2019-11-03 18:56:22 +0200 |
commit | f4a987912a3bc7012cbfeaaa35ea94e5f97655e0 (patch) | |
tree | d0761fc104f964d99e1a25b68f4435b5095f196d /ext/mixed | |
parent | 75ff05148d5a07c397d11b8bfbc92833be8726ea (diff) |
prevent accidental lookup on glossary text select
Diffstat (limited to 'ext/mixed')
-rw-r--r-- | ext/mixed/js/display.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index bdc5e962..81072957 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -35,6 +35,7 @@ class Display { this.persistentEventListeners = []; this.interactive = false; this.eventListenersActive = false; + this.clickScanPrevent = false; this.windowScroll = new WindowScroll(); @@ -81,6 +82,22 @@ class Display { } } + onGlossaryMousedown(e) { + if (Frontend.isMouseButton('primary', e)) { + this.clickScanPrevent = false; + } + } + + onGlossaryMouseMove(e) { + this.clickScanPrevent = true; + } + + onGlossaryMouseup(e) { + if (!this.clickScanPrevent && Frontend.isMouseButton('primary', e)) { + this.onTermLookup(e); + } + } + async onTermLookup(e) { try { e.preventDefault(); @@ -252,7 +269,9 @@ class Display { this.addEventListeners('.kanji-link', 'click', this.onKanjiLookup.bind(this)); this.addEventListeners('.source-term', 'click', this.onSourceTermView.bind(this)); if (this.options.scanning.enablePopupSearch) { - this.addEventListeners('.glossary-item', 'click', this.onTermLookup.bind(this)); + this.addEventListeners('.glossary-item', 'mouseup', this.onGlossaryMouseup.bind(this)); + this.addEventListeners('.glossary-item', 'mousedown', this.onGlossaryMousedown.bind(this)); + this.addEventListeners('.glossary-item', 'mousemove', this.onGlossaryMouseMove.bind(this)); } } else { Display.clearEventListeners(this.eventListeners); |