From 46d18018606da0fdfd592d4580dddeb55172f92b Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Wed, 8 Nov 2023 12:32:05 +0700 Subject: [PATCH] feat(web): flicks auto-finish upon new tap --- .../gestures/matchers/gestureMatcher.ts | 4 +-- .../osk/src/input/gestures/browser/flick.ts | 7 +++-- .../osk/src/input/gestures/specsForLayout.ts | 26 ++++++++++++------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/common/web/gesture-recognizer/src/engine/headless/gestures/matchers/gestureMatcher.ts b/common/web/gesture-recognizer/src/engine/headless/gestures/matchers/gestureMatcher.ts index 636f5693b7..b552eca858 100644 --- a/common/web/gesture-recognizer/src/engine/headless/gestures/matchers/gestureMatcher.ts +++ b/common/web/gesture-recognizer/src/engine/headless/gestures/matchers/gestureMatcher.ts @@ -264,9 +264,7 @@ export class GestureMatcher implements PredecessorMatch< if(matched && contactSpec.endOnResolve) { matcher.source.terminate(false); } else if(!matched && contactSpec.endOnReject) { - // Ending due to gesture-rejection effectively means to cancel the path, - // so signal exactly that. - matcher.source.terminate(true); + matcher.source.terminate(false); } } } diff --git a/web/src/engine/osk/src/input/gestures/browser/flick.ts b/web/src/engine/osk/src/input/gestures/browser/flick.ts index 7f7e23bb2e..aa344164b4 100644 --- a/web/src/engine/osk/src/input/gestures/browser/flick.ts +++ b/web/src/engine/osk/src/input/gestures/browser/flick.ts @@ -167,12 +167,11 @@ export default class Flick implements GestureHandler { private emitKey(vkbd: VisualKeyboard, selection: ActiveKeyBase, pathStats: CumulativePathStats) { let keyEvent: KeyEvent; const projectedDistance = calcLockedDistance(pathStats, this.lockedDir); - if(projectedDistance < this.gestureParams.flick.dirLockDist) { - keyEvent = vkbd.keyEventFromSpec(this.baseSpec); - } else if(projectedDistance >= this.gestureParams.flick.triggerDist) { + if(projectedDistance > this.gestureParams.flick.triggerDist) { keyEvent = vkbd.keyEventFromSpec(selection); } else { - return; + // Even if mid-way between base key and actual key. + keyEvent = vkbd.keyEventFromSpec(this.baseSpec); } keyEvent.keyDistribution = this.currentStageKeyDistribution(this.baseKeyDistances); diff --git a/web/src/engine/osk/src/input/gestures/specsForLayout.ts b/web/src/engine/osk/src/input/gestures/specsForLayout.ts index bd9c46e646..a72c8562c7 100644 --- a/web/src/engine/osk/src/input/gestures/specsForLayout.ts +++ b/web/src/engine/osk/src/input/gestures/specsForLayout.ts @@ -658,9 +658,20 @@ export function flickMidModel(params: GestureParams): GestureModel { resolutionPriority: 0, contacts: [ { - model: flickMidContactModel(params) - }, + model: flickMidContactModel(params), + endOnReject: true, + }, { + model: InstantContactRejectionModel, + resetOnResolve: true, + } ], + rejectionActions: { + // Only 'rejects' in this form if the path is completed before direction-locking state. + path: { + type: 'replace', + replace: 'flick-reset-end' + } + }, resolutionAction: { type: 'chain', item: 'none', @@ -674,13 +685,6 @@ export function flickResetModel(params: GestureParams): GestureModel { return { ...base, id: 'flick-reset', - rejectionActions: { - // Only 'rejects' in this form if the path is completed before direction-locking state. - path: { - type: 'replace', - replace: 'flick-reset-end' - } - }, resolutionAction: { type: 'chain', next: 'flick-end' @@ -710,6 +714,10 @@ export function flickEndModel(params: GestureParams): GestureModel { { model: flickEndContactModel(params) }, + { + model: InstantContactResolutionModel, + resetOnResolve: true + } ], rejectionActions: { path: {