diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-05-19 20:09:37 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-19 20:09:37 -0400 |
commit | 6184bcb812686f5498ee982ae89da88792b9a880 (patch) | |
tree | b64fd9b45fe8909c3c5e553af701e6ae18fc0170 /ext/js/app/frontend.js | |
parent | eddd0288643f08d2a2c85f73575bc7ee1c157539 (diff) |
Selection clear improvements (#1690)
* Update selection clear process
* Clean up old clearSelection API
* Update clear order
* Add clear event handling
Diffstat (limited to 'ext/js/app/frontend.js')
-rw-r--r-- | ext/js/app/frontend.js | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/ext/js/app/frontend.js b/ext/js/app/frontend.js index 7913d7d8..e40b400d 100644 --- a/ext/js/app/frontend.js +++ b/ext/js/app/frontend.js @@ -121,7 +121,7 @@ class Frontend { yomichan.on('closePopups', this._onClosePopups.bind(this)); chrome.runtime.onMessage.addListener(this._onRuntimeMessage.bind(this)); - this._textScanner.on('clearSelection', this._onClearSelection.bind(this)); + this._textScanner.on('clear', this._onTextScannerClear.bind(this)); this._textScanner.on('searched', this._onSearched.bind(this)); yomichan.crossFrame.registerHandlers([ @@ -253,13 +253,8 @@ class Frontend { this._updateContentScale(); } - _onClearSelection({passive}) { - this._stopClearSelectionDelayed(); - if (this._popup !== null) { - this._popup.hide(!passive); - this._popup.clearAutoPlayTimer(); - this._isPointerOverPopup = false; - } + _onTextScannerClear() { + this._clearSelection(false); } _onSearched({type, dictionaryEntries, sentence, inputInfo: {eventType, passive, detail}, textSource, optionsContext, detail: {documentTitle}, error}) { @@ -299,7 +294,12 @@ class Frontend { _clearSelection(passive) { this._stopClearSelectionDelayed(); - this._textScanner.clearSelection(passive); + if (this._popup !== null) { + this._popup.clearAutoPlayTimer(); + this._popup.hide(!passive); + this._isPointerOverPopup = false; + } + this._textScanner.clearSelection(); } _clearSelectionDelayed(delay, restart, passive) { @@ -566,6 +566,7 @@ class Frontend { _updateTextScannerEnabled() { const enabled = (this._options !== null && this._options.general.enable && !this._disabledOverride); this._textScanner.setEnabled(enabled); + this._clearSelection(true); } _updateContentScale() { |