Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multi-touch (additional touches causing jumps) #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fortinmike
Copy link

This is the same fix as #33, but this new pull request contains only the relevant changes (I forgot to create a branch before creating my original pull request).


Considering ev.targetTouches[0] before ev.changedTouches[0] in normalizeEvent() meant that having multiple target touches where the first touch wasn't the same as the one stored by Impetus as the "pointer" would prevent the condition in onUp() from triggering, leaving the internal state in "started" mode (stopTracking() not called) event after all touches had been released. In essence, onUp() was called twice (once for each released touch) but in both cases it tested ev.targetTouches[0] which didn't match the stored "pointer" touch, which was at index 1, causing stopTracking() never to be called.

Unless I'm missing something, as the various event handlers already filter out "unwanted" touches (by storing the first touch's id and checking against that), event normalization can safely consider changed touches only (the touch concerned by the current event), which fixes at least this edge case and makes tracking more reliable when multiple touches are present.

Before (video)
After (video)

Considering `ev.targetTouches[0]` before `ev.changedTouches[0]` in `normalizeEvent()` meant that having multiple target touches where the first touch wasn't the same as the one stored by Impetus as the "pointer" would prevent the condition in `onUp()` from triggering, leaving the internal state in "started" mode (`stopTracking()` not called) event after all touches had been released. In essence, `onUp()` was called twice (once for each released touch) but in both cases it tested `ev.targetTouches[0]` which didn't match the stored "pointer" touch, which was at index 0, causing `stopTracking()` never to be called.
@fortinmike fortinmike changed the title Fix additional touches blocking tracking stop Fix multi-touch (additional touches causing jumps) Dec 3, 2018
romellem added a commit to romellem/impulsion that referenced this pull request Apr 2, 2020
@see chrisbateman/impetus#44

> additional touches causing jumps
romellem added a commit to romellem/impulsion that referenced this pull request Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant