Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Capture pointerdown button state for determining mouse tap
Browse files Browse the repository at this point in the history
pointerup will fire with *current buttons status*, not the button that was just released.

Fixes #28
  • Loading branch information
dfreedm committed Mar 1, 2014
1 parent 0ccb422 commit f635375
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
if (inEvent.isPrimary && !inEvent.tapPrevented) {
pointermap.set(inEvent.pointerId, {
target: inEvent.target,
buttons: inEvent.buttons,
x: inEvent.clientX,
y: inEvent.clientY
});
Expand All @@ -63,15 +64,19 @@
}
}
},
shouldTap: function(e) {
shouldTap: function(e, downState) {
if (!e.tapPrevented) {
// only allow left click to tap for mouse
return e.pointerType === 'mouse' ? e.buttons === 1 : true;
if (e.pointerType === 'mouse') {
// only allow left click to tap for mouse
return downState.buttons === 1;
} else {
return true;
}
}
},
pointerup: function(inEvent) {
var start = pointermap.get(inEvent.pointerId);
if (start && this.shouldTap(inEvent)) {
if (start && this.shouldTap(inEvent, start)) {
var t = scope.findLCA(start.target, inEvent.target);
if (t) {
var e = dispatcher.makeEvent('tap', {
Expand Down

0 comments on commit f635375

Please sign in to comment.