From d7a1e3bb6259f9e5277ff2736f3fd31631ecf011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Fortin?= Date: Tue, 26 Sep 2017 11:21:48 -0400 Subject: [PATCH] Fix additional touches blocking tracking stop 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. --- src/Impetus.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Impetus.js b/src/Impetus.js index 920d895..3826209 100644 --- a/src/Impetus.js +++ b/src/Impetus.js @@ -159,7 +159,7 @@ export default class Impetus { */ function normalizeEvent(ev) { if (ev.type === 'touchmove' || ev.type === 'touchstart' || ev.type === 'touchend') { - var touch = ev.targetTouches[0] || ev.changedTouches[0]; + var touch = ev.changedTouches[0]; return { x: touch.clientX, y: touch.clientY,