feat(web): flicks auto-finish upon new tap

This commit is contained in:
Joshua A. Horton 2023-11-08 12:32:05 +07:00
parent a1974dcbde
commit 46d1801860
3 changed files with 21 additions and 16 deletions

View file

@ -264,9 +264,7 @@ export class GestureMatcher<Type, StateToken = any> 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);
}
}
}

View file

@ -167,12 +167,11 @@ export default class Flick implements GestureHandler {
private emitKey(vkbd: VisualKeyboard, selection: ActiveKeyBase, pathStats: CumulativePathStats<any>) {
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);

View file

@ -658,9 +658,20 @@ export function flickMidModel(params: GestureParams): GestureModel<any> {
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<any> {
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<any> {
{
model: flickEndContactModel(params)
},
{
model: InstantContactResolutionModel,
resetOnResolve: true
}
],
rejectionActions: {
path: {