Closed fortinmike closed 5 years ago
+1 for this PR: applying it on our project allowed us to fix a bug. We were exactly in the edge case described by @fortinmike.
@chrisbateman Feedback in #13 seems to indicate that this pull request is a keeper. Would you consider reviewing this and merging into master? Currently the impetus library is broken for all its users when using multi-touch.
+1 for this one.
Closing this because I created a new pull request which contains only the relevant changes.
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)