Skip to content

Commit

Permalink
Update 'pointerWasMoved' even with no 'prepared'
Browse files Browse the repository at this point in the history
This way tap events don't fire when the pointer was moved but there was
no drag/resize/gesture.
  • Loading branch information
taye committed Aug 2, 2014
1 parent 99f2f7c commit 6aacb39
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions interact.js
Original file line number Diff line number Diff line change
Expand Up @@ -1674,6 +1674,8 @@
return;
}

pointerIsDown = true;

var eventTarget = (event.target instanceof SVGElementInstance
? event.target.correspondingUseElement
: event.target),
Expand Down Expand Up @@ -1743,7 +1745,6 @@
}

if (action) {
pointerIsDown = true;
prepared = action;

return pointerDown(event, action);
Expand Down Expand Up @@ -1805,8 +1806,6 @@
return event;
}

pointerWasMoved = false;

if (options.styleCursor) {
document.documentElement.style.cursor = actions[action].cursor;
}
Expand Down Expand Up @@ -2067,14 +2066,6 @@
setEventXY(curCoords, event);
}

// return if there is no prepared action
if (!prepared
// or this is a mousemove event but the down event was a touch
|| (event.type === 'mousemove' && downEvent.type === 'touchstart')) {

return;
}

var dx, dy;

// register movement of more than 1 pixel
Expand All @@ -2085,6 +2076,14 @@
pointerWasMoved = hypot(dx, dy) > 1;
}

// return if there is no prepared action
if (!prepared
// or this is a mousemove event but the down event was a touch
|| (event.type === 'mousemove' && downEvent.type === 'touchstart')) {

return;
}

if (pointerWasMoved
// ignore movement while inertia is active
&& (!inertiaStatus.active || (event instanceof InteractEvent && /inertiastart/.test(event.type)))) {
Expand Down Expand Up @@ -2444,7 +2443,7 @@
}

function pointerOver (event) {
if (pointerIsDown || dragging || resizing || gesturing) { return; }
if (prepared) { return; }

var curMatches = [],
prevTargetElement = target && target._element,
Expand Down Expand Up @@ -2510,7 +2509,7 @@
}

function pointerOut (event) {
if (pointerIsDown || dragging || resizing || gesturing) { return; }
if (prepared) { return; }

// Remove temporary event listeners for selector Interactables
var eventTarget = (event.target instanceof SVGElementInstance
Expand All @@ -2529,7 +2528,7 @@
// Check what action would be performed on pointerMove target if a mouse
// button were pressed and change the cursor accordingly
function pointerHover (event, matches) {
if (!(pointerIsDown || dragging || resizing || gesturing)) {
if (!prepared) {

var action;

Expand Down

0 comments on commit 6aacb39

Please sign in to comment.