Update TextScanner.setEnabled to not reset state if unnecessary (#817)
This commit is contained in:
parent
c98aa9ad47
commit
9f1753a565
@ -51,6 +51,7 @@ class TextScanner extends EventDispatcher {
|
|||||||
this._inputs = [];
|
this._inputs = [];
|
||||||
|
|
||||||
this._enabled = false;
|
this._enabled = false;
|
||||||
|
this._enabledValue = false;
|
||||||
this._eventListeners = new EventListenerCollection();
|
this._eventListeners = new EventListenerCollection();
|
||||||
|
|
||||||
this._primaryTouchIdentifier = null;
|
this._primaryTouchIdentifier = null;
|
||||||
@ -84,6 +85,9 @@ class TextScanner extends EventDispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setEnabled(enabled) {
|
setEnabled(enabled) {
|
||||||
|
const value = enabled && this._isPrepared;
|
||||||
|
if (this._enabledValue === value) { return; }
|
||||||
|
|
||||||
this._eventListeners.removeAllEventListeners();
|
this._eventListeners.removeAllEventListeners();
|
||||||
this._primaryTouchIdentifier = null;
|
this._primaryTouchIdentifier = null;
|
||||||
this._preventNextContextMenu = false;
|
this._preventNextContextMenu = false;
|
||||||
@ -92,8 +96,9 @@ class TextScanner extends EventDispatcher {
|
|||||||
this._preventScroll = false;
|
this._preventScroll = false;
|
||||||
|
|
||||||
this._enabled = enabled;
|
this._enabled = enabled;
|
||||||
|
this._enabledValue = value;
|
||||||
|
|
||||||
if (this._enabled && this._isPrepared) {
|
if (value) {
|
||||||
this._hookEvents();
|
this._hookEvents();
|
||||||
} else {
|
} else {
|
||||||
this.clearSelection(true);
|
this.clearSelection(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user