aboutsummaryrefslogtreecommitdiff
path: root/ext/js/language/text-scanner.js
diff options
context:
space:
mode:
authorKuuuube <61125188+Kuuuube@users.noreply.github.com>2024-04-14 12:48:25 -0400
committerGitHub <noreply@github.com>2024-04-14 16:48:25 +0000
commit7df7e1b2bf475edd771a73a950004ab8d5f85ccb (patch)
treea4aa178c144780968477a105d29eeeffe215c7ed /ext/js/language/text-scanner.js
parentf2b3eb4eddb282d4eb88488b3dbc47c948891a6d (diff)
Add scanOnTouchTap and improve touch scanning defaults (#791)24.4.14.0
* Add scanOnTouchTap * Update version to 30 * Cleanup if statement
Diffstat (limited to 'ext/js/language/text-scanner.js')
-rw-r--r--ext/js/language/text-scanner.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/ext/js/language/text-scanner.js b/ext/js/language/text-scanner.js
index ad5ba12b..bdbc117e 100644
--- a/ext/js/language/text-scanner.js
+++ b/ext/js/language/text-scanner.js
@@ -137,6 +137,8 @@ export class TextScanner extends EventDispatcher {
/** @type {() => void} */
this._preventNextClickScanTimerCallback = this._onPreventNextClickScanTimeout.bind(this);
+ /** @type {boolean} */
+ this._touchTapValid = false;
/** @type {?number} */
this._primaryTouchIdentifier = null;
/** @type {boolean} */
@@ -662,6 +664,7 @@ export class TextScanner extends EventDispatcher {
this._preventNextContextMenu = false;
this._preventNextMouseDown = false;
this._preventNextClick = false;
+ this._touchTapValid = true;
const selection = window.getSelection();
if (selection !== null && isPointInSelection(x, y, selection)) {
@@ -707,9 +710,10 @@ export class TextScanner extends EventDispatcher {
if (!allowSearch) { return; }
const inputInfo = this._getMatchingInputGroupFromEvent('touch', 'touchEnd', e);
- if (inputInfo === null || !(inputInfo.input !== null && inputInfo.input.scanOnTouchRelease)) { return; }
-
- void this._searchAtFromTouchEnd(x, y, inputInfo);
+ if (inputInfo === null || inputInfo.input === null) { return; }
+ if (inputInfo.input.scanOnTouchRelease || (inputInfo.input.scanOnTouchTap && this._touchTapValid)) {
+ void this._searchAtFromTouchEnd(x, y, inputInfo);
+ }
}
/**
@@ -728,6 +732,8 @@ export class TextScanner extends EventDispatcher {
* @param {TouchEvent} e
*/
_onTouchMove(e) {
+ this._touchTapValid = false;
+
if (this._primaryTouchIdentifier === null) { return; }
if (!e.cancelable) {
@@ -1477,6 +1483,7 @@ export class TextScanner extends EventDispatcher {
scanOnTouchMove: this._getInputBoolean(options.scanOnTouchMove),
scanOnTouchPress: this._getInputBoolean(options.scanOnTouchPress),
scanOnTouchRelease: this._getInputBoolean(options.scanOnTouchRelease),
+ scanOnTouchTap: this._getInputBoolean(options.scanOnTouchTap),
scanOnPenMove: this._getInputBoolean(options.scanOnPenMove),
scanOnPenHover: this._getInputBoolean(options.scanOnPenHover),
scanOnPenReleaseHover: this._getInputBoolean(options.scanOnPenReleaseHover),