Skip to content

Commit 3cc9d0b

Browse files
committed
Ignore tap from simulated mouse events after touch
1 parent 272d174 commit 3cc9d0b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

interact.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@
233233
// Less Precision with touch input
234234
margin = supportsTouch || supportsPointerEvent? 20: 10,
235235

236+
// for ignoring taps from browser's simulated mouse events
237+
prevTouchTapTime = 0,
238+
236239
// Allow this many interactions to happen simultaneously
237240
maxInteractions = 1,
238241

@@ -2354,6 +2357,10 @@
23542357

23552358
this.tapTime = tap.timeStamp;
23562359

2360+
if (!this.mouse) {
2361+
prevTouchTapTime = this.tapTime;
2362+
}
2363+
23572364
for (i = 0; i < targets.length; i++) {
23582365
var origin = getOriginXY(targets[i], elements[i]);
23592366

@@ -2397,7 +2404,9 @@
23972404
},
23982405

23992406
collectTaps: function (pointer, event, eventTarget) {
2400-
if(this.pointerWasMoved || !(this.downTarget && this.downTarget === eventTarget)) {
2407+
if(this.pointerWasMoved
2408+
|| !(this.downTarget && this.downTarget === eventTarget)
2409+
|| (this.mouse && (new Date().getTime() - prevTouchTapTime) < 300)) {
24012410
return;
24022411
}
24032412

0 commit comments

Comments
 (0)