Update TextScanner.setEnabled to not reset state if unnecessary (#817)

This commit is contained in:
toasted-nutbread 2020-09-12 19:36:51 -04:00 committed by GitHub
parent c98aa9ad47
commit 9f1753a565
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);