Replace getIndexOfTouch with getTouch
This commit is contained in:
parent
7afc23427e
commit
b0c566417f
@ -158,7 +158,7 @@ class TextScanner {
|
|||||||
onTouchEnd(e) {
|
onTouchEnd(e) {
|
||||||
if (
|
if (
|
||||||
this.primaryTouchIdentifier === null ||
|
this.primaryTouchIdentifier === null ||
|
||||||
TextScanner.getIndexOfTouch(e.changedTouches, this.primaryTouchIdentifier) < 0
|
TextScanner.getTouch(e.changedTouches, this.primaryTouchIdentifier) === null
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -181,13 +181,11 @@ class TextScanner {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const touches = e.changedTouches;
|
const primaryTouch = TextScanner.getTouch(e.changedTouches, this.primaryTouchIdentifier);
|
||||||
const index = TextScanner.getIndexOfTouch(touches, this.primaryTouchIdentifier);
|
if (primaryTouch === null) {
|
||||||
if (index < 0) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const primaryTouch = touches[index];
|
|
||||||
this.searchAt(primaryTouch.clientX, primaryTouch.clientY, 'touchMove');
|
this.searchAt(primaryTouch.clientX, primaryTouch.clientY, 'touchMove');
|
||||||
|
|
||||||
e.preventDefault(); // Disable scroll
|
e.preventDefault(); // Disable scroll
|
||||||
@ -356,13 +354,12 @@ class TextScanner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static getIndexOfTouch(touchList, identifier) {
|
static getTouch(touchList, identifier) {
|
||||||
for (const i in touchList) {
|
for (const touch of touchList) {
|
||||||
const t = touchList[i];
|
if (touch.identifier === identifier) {
|
||||||
if (t.identifier === identifier) {
|
return touch;
|
||||||
return i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user