Fix multi-touch (additional touches causing jumps) #44
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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]
beforeev.changedTouches[0]
innormalizeEvent()
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 inonUp()
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 testedev.targetTouches[0]
which didn't match the stored "pointer" touch, which was at index 1, causingstopTracking()
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)