diff --git a/src/standard/gestures.html b/src/standard/gestures.html
index f5e13ad4ae..5681e907b0 100644
--- a/src/standard/gestures.html
+++ b/src/standard/gestures.html
@@ -38,6 +38,17 @@
}
})();
+ // check for passive event listeners
+ var SUPPORTS_PASSIVE = (function() {
+ var sp = false;
+ try {
+ var opts = Object.defineProperty({}, 'passive', {get: function() {sp = true;}})
+ window.addEventListener('test', null, opts);
+ window.removeEventListener('test', null, opts);
+ return sp;
+ } catch(e) {}
+ })();
+
// Check for touch-only devices
var IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/);
@@ -82,7 +93,7 @@
}
}
- function ignoreMouse() {
+ function ignoreMouse(ev) {
if (!POINTERSTATE.mouse.mouseIgnoreJob) {
setupTeardownMouseCanceller(true);
}
@@ -91,6 +102,7 @@
POINTERSTATE.mouse.target = null;
POINTERSTATE.mouse.mouseIgnoreJob = null;
};
+ POINTERSTATE.mouse.target = Polymer.dom(ev).rootTarget;
POINTERSTATE.mouse.mouseIgnoreJob =
Polymer.Debounce(POINTERSTATE.mouse.mouseIgnoreJob, unset, MOUSE_TIMEOUT);
}
@@ -178,6 +190,10 @@
stateObj.upfn = null;
}
+ if (HAS_NATIVE_TA) {
+ document.addEventListener('touchend', ignoreMouse, SUPPORTS_PASSIVE ? {passive: true} : false);
+ }
+
var Gestures = {
gestures: {},
recognizers: [],
@@ -234,14 +250,11 @@
if (!HAS_NATIVE_TA) {
if (type === 'touchstart' || type === 'touchmove') {
Gestures.handleTouchAction(ev);
+ } else if (type === 'touchend') {
+ // ignore syntethic mouse events after a touch
+ ignoreMouse(ev);
}
}
- // disable synth mouse events, unless this event is itself simulated
- if (type === 'touchend') {
- POINTERSTATE.mouse.target = Polymer.dom(ev).rootTarget;
- // ignore syntethic mouse events after a touch
- ignoreMouse();
- }
}
}
handled = ev[HANDLED_OBJ];