diff --git a/src/standard/gestures.html b/src/standard/gestures.html index a592f76159..2bc4ccb3cc 100644 --- a/src/standard/gestures.html +++ b/src/standard/gestures.html @@ -41,12 +41,24 @@ // Check for touch-only devices var IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/); + // Check for sourceCapabilities, used to distinguish synthetic events + var HAS_SOURCE_CAPS = 'sourceCapabilities' in UIEvent.prototype; + // touch will make synthetic mouse events // `preventDefault` on touchend will cancel them, // but this breaks `` focus and link clicks // disable mouse handlers for MOUSE_TIMEOUT ms after // a touchend to ignore synthetic mouse events var mouseCanceller = function(mouseEvent) { + if (HAS_SOURCE_CAPS) { + // if mouseEvent did not come from a device that fires touch events, + // it was made by a real mouse and should be counted + // http://wicg.github.io/InputDeviceCapabilities/#dom-inputdevicecapabilities-firestouchevents + var sc = mouseEvent.sourceCapabilities; + if (sc && !sc.firesTouchEvents) { + return; + } + } // skip synthetic mouse events mouseEvent[HANDLED_OBJ] = {skip: true}; // disable "ghost clicks" diff --git a/test/smoke/gesture-import.html b/test/smoke/gesture-import.html index 379d93d55d..39b9ddacaf 100644 --- a/test/smoke/gesture-import.html +++ b/test/smoke/gesture-import.html @@ -4,13 +4,13 @@