Skip to content

Commit

Permalink
fix(web): gesture-model did not check start-item conditions for first…
Browse files Browse the repository at this point in the history
… source
  • Loading branch information
jahorton committed Sep 22, 2023
1 parent be19674 commit 4f182d8
Showing 1 changed file with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export class GestureMatcher<Type> implements PredecessorMatch<Type> {
return this.predecessor.primaryPath;
}

return bestMatcher.source;
return bestMatcher?.source;
}

public get baseItem(): Type {
Expand Down Expand Up @@ -276,9 +276,19 @@ export class GestureMatcher<Type> implements PredecessorMatch<Type> {
throw new Error(`The specified gesture model does not support more than ${existingContacts} contact points.`);
}

this.addContactInternal(simpleSource.constructSubview(false, true));
}

public get result() {
return this._result;
}

private addContactInternal(simpleSource: GestureSourceSubview<Type>) {
// The number of already-active contacts tracked for this gesture
const contactSpec = this.model.contacts[existingContacts];
const existingContacts = this.pathMatchers.length;

const contactSpec = this.model.contacts[existingContacts];
const contactModel = new PathMatcher(contactSpec.model, simpleSource);
let baseItem: Type = null;
if(existingContacts) {
// just use the highest-priority item source's base item and call it a day.
Expand All @@ -300,26 +310,13 @@ export class GestureMatcher<Type> implements PredecessorMatch<Type> {
}

if(contactSpec.model.allowsInitialState) {
const initialStateCheck = contactSpec.model.allowsInitialState(simpleSource.currentSample, this.primaryPath.currentSample, baseItem);
const initialStateCheck = contactSpec.model.allowsInitialState(simpleSource.currentSample, this.primaryPath?.currentSample, baseItem);

if(!initialStateCheck) {
this.finalize(false, 'path');
}
}

this.addContactInternal(simpleSource.constructSubview(false, true));
}

public get result() {
return this._result;
}

private addContactInternal(simpleSource: GestureSourceSubview<Type>) {
const existingContacts = this.pathMatchers.length;

// The number of already-active contacts tracked for this gesture
const contactSpec = this.model.contacts[existingContacts];
const contactModel = new PathMatcher(contactSpec.model, simpleSource);
contactModel.promise.then((resolution) => {
this.finalize(resolution.type == 'resolve', resolution.cause);
});
Expand Down

0 comments on commit 4f182d8

Please sign in to comment.