From 9703e123bf7467fc990e6d38e59bcc5fd46645b8 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Thu, 24 Oct 2019 21:38:19 -0400 Subject: Remove setPrimaryTouch --- ext/fg/js/frontend.js | 67 ++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 38 deletions(-) diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 223088a1..8d51c1df 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -168,7 +168,28 @@ class Frontend { return; } - this.setPrimaryTouch(primaryTouch); + this.primaryTouchIdentifier = primaryTouch.identifier; + this.preventScroll = false; + this.preventNextContextMenu = false; + this.preventNextMouseDown = false; + this.preventNextClick = false; + + const textSourceCurrentPrevious = this.textSourceCurrent !== null ? this.textSourceCurrent.clone() : null; + + this.searchAt(primaryTouch.clientX, primaryTouch.clientY, 'touchStart') + .then(() => { + if ( + this.pendingLookup || + this.textSourceCurrent === null || + this.textSourceCurrent.equals(textSourceCurrentPrevious) + ) { + return; + } + + this.preventScroll = true; + this.preventNextContextMenu = true; + this.preventNextMouseDown = true; + }); } onTouchEnd(e) { @@ -179,7 +200,13 @@ class Frontend { return; } - this.setPrimaryTouch(null); + this.primaryTouchIdentifier = null; + this.preventScroll = false; + this.preventNextClick = false; + // Don't revert context menu and mouse down prevention, + // since these events can occur after the touch has ended. + // this.preventNextContextMenu = false; + // this.preventNextMouseDown = false; } onTouchCancel(e) { @@ -419,42 +446,6 @@ class Frontend { return -1; } - setPrimaryTouch(touch) { - if (touch === null) { - this.primaryTouchIdentifier = null; - this.preventScroll = false; - this.preventNextClick = false; - // Don't revert context menu and mouse down prevention, - // since these events can occur after the touch has ended. - // this.preventNextContextMenu = false; - // this.preventNextMouseDown = false; - } - else { - this.primaryTouchIdentifier = touch.identifier; - this.preventScroll = false; - this.preventNextContextMenu = false; - this.preventNextMouseDown = false; - this.preventNextClick = false; - - const textSourceCurrentPrevious = this.textSourceCurrent !== null ? this.textSourceCurrent.clone() : null; - - this.searchAt(touch.clientX, touch.clientY, 'touchStart') - .then(() => { - if ( - this.pendingLookup || - this.textSourceCurrent === null || - this.textSourceCurrent.equals(textSourceCurrentPrevious) - ) { - return; - } - - this.preventScroll = true; - this.preventNextContextMenu = true; - this.preventNextMouseDown = true; - }); - } - } - static selectionContainsPoint(selection, x, y) { for (let i = 0; i < selection.rangeCount; ++i) { const range = selection.getRangeAt(i); -- cgit v1.2.3