diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-09-12 19:36:51 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-12 19:36:51 -0400 |
commit | 9f1753a565a617cfddd861818de12eadd2a11258 (patch) | |
tree | 087efbae34f20f69c33ccee3d2a8ef5cac0bbafa /ext | |
parent | c98aa9ad4751f1c35c164525eaec7e2411b0a5c4 (diff) |
Update TextScanner.setEnabled to not reset state if unnecessary (#817)
Diffstat (limited to 'ext')
-rw-r--r-- | ext/mixed/js/text-scanner.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js index b2a5508c..26c0687b 100644 --- a/ext/mixed/js/text-scanner.js +++ b/ext/mixed/js/text-scanner.js @@ -51,6 +51,7 @@ class TextScanner extends EventDispatcher { this._inputs = []; this._enabled = false; + this._enabledValue = false; this._eventListeners = new EventListenerCollection(); this._primaryTouchIdentifier = null; @@ -84,6 +85,9 @@ class TextScanner extends EventDispatcher { } setEnabled(enabled) { + const value = enabled && this._isPrepared; + if (this._enabledValue === value) { return; } + this._eventListeners.removeAllEventListeners(); this._primaryTouchIdentifier = null; this._preventNextContextMenu = false; @@ -92,8 +96,9 @@ class TextScanner extends EventDispatcher { this._preventScroll = false; this._enabled = enabled; + this._enabledValue = value; - if (this._enabled && this._isPrepared) { + if (value) { this._hookEvents(); } else { this.clearSelection(true); |