Skip to content

Commit

Permalink
cleanup check for sourceCapabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreedm committed Jul 21, 2016
1 parent ed4c18a commit 4c44fb7
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/standard/gestures.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,19 @@
// 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 `<input>` 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;
}
// Check for sourceCapabilities, used to distinguish synthetic events
// 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};
Expand Down

0 comments on commit 4c44fb7

Please sign in to comment.