Skip to content

Commit 18bf9d4

Browse files
committed
Expose public API to reset mouse cancelling for testing touch
Remove undocument `event.__polymerSyntheticTouch` hack Fixes #3540
1 parent e0bcda8 commit 18bf9d4

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

‎src/standard/gestures.html‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@
231231
}
232232
}
233233
// disable synth mouse events, unless this event is itself simulated
234-
if (type === 'touchend' && !ev.__polymerSimulatedTouch) {
234+
if (type === 'touchend') {
235235
POINTERSTATE.mouse.target = Polymer.dom(ev).rootTarget;
236236
// ignore syntethic mouse events after a touch
237-
ignoreMouse(true);
237+
ignoreMouse();
238238
}
239239
}
240240
}
@@ -404,6 +404,20 @@
404404
if (recognizer.info) {
405405
recognizer.info.prevent = true;
406406
}
407+
},
408+
/**
409+
* Reset the 2500ms timeout on processing mouse input after detecting touch input.
410+
*
411+
* Touch inputs create synthesized mouse inputs anywhere from 0 to 2000ms after the touch.
412+
* This method should only be called during testing with simulated touch inputs.
413+
* Calling this method in production may cause duplicate taps or other gestures.
414+
*
415+
* @method resetMouseCanceller
416+
*/
417+
resetMouseCanceller: function() {
418+
if (POINTERSTATE.mouse.mouseIgnoreJob) {
419+
POINTERSTATE.mouse.mouseIgnoreJob.complete();
420+
}
407421
}
408422
};
409423

‎test/unit/gestures.html‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@
256256
});
257257
teardown(function() {
258258
el.parentNode.removeChild(el);
259+
Polymer.Gestures.resetMouseCanceller();
259260
});
260261

261262
test('tap', function() {
@@ -313,7 +314,6 @@
313314
];
314315
ev.clientX = clientX;
315316
ev.clientY = clientY;
316-
ev.__polymerSimulatedTouch = true;
317317
child.dispatchEvent(ev);
318318

319319
for (var i = 0; i < 10; i++) {
@@ -330,7 +330,6 @@
330330
ev.clientX = clientX;
331331
ev.clientY = clientY;
332332
// tell gestures to not turn off mouse events
333-
ev.__polymerSimulatedTouch = true;
334333
child.dispatchEvent(ev);
335334
}
336335

0 commit comments

Comments
 (0)