From 5a607a01ea86e505f1f350dff1794ee4e202f86f Mon Sep 17 00:00:00 2001 From: "Joshua A. Horton" Date: Fri, 22 Sep 2023 09:42:08 +0700 Subject: [PATCH] fix(web): base item for first source matching a gesture-model --- .../headless/gestures/matchers/gestureMatcher.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 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 b32df366bc..619036e8fa 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 @@ -299,11 +299,13 @@ export class GestureMatcher implements PredecessorMatch { const contactSpec = this.model.contacts[existingContacts]; const contactModel = new PathMatcher(contactSpec.model, simpleSource); + // Add it early, as we need it to be accessible for reference via .primaryPath stuff below. + this.pathMatchers.push(contactModel); + let baseItem: Type = null; - if(existingContacts) { - // just use the highest-priority item source's base item and call it a day. - baseItem = this.primaryPath.baseItem; - } else if(this.predecessor && this.model.sustainTimer) { + // If there were no existing contacts but a predecessor exists and a sustain timer + // has been specified, it needs special base-item handling. + if(!existingContacts && this.predecessor && this.model.sustainTimer) { const baseItemMode = this.model.sustainTimer.baseItem ?? 'result'; switch(baseItemMode) { @@ -317,6 +319,10 @@ export class GestureMatcher implements PredecessorMatch { baseItem = this.predecessor.result.action.item; break; } + } else { + // just use the highest-priority item source's base item and call it a day. + // There's no need to refer to some previously-existing source for comparison. + baseItem = this.primaryPath.baseItem; } if(contactSpec.model.allowsInitialState) { @@ -330,8 +336,6 @@ export class GestureMatcher implements PredecessorMatch { contactModel.promise.then((resolution) => { this.finalize(resolution.type == 'resolve', resolution.cause); }); - - this.pathMatchers.push(contactModel); } update() {