Skip to content

Commit

Permalink
Merge pull request #77 from limonte/patch-3
Browse files Browse the repository at this point in the history
Fix touch support detecting
  • Loading branch information
notwaldorf authored Feb 23, 2017
2 parents 75f4313 + 82e41da commit e097890
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions mock-interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
} catch (_) {}
return has;
})();

var HAS_NEW_TOUCH = (function() {
var has = false;
try {
has = Boolean(new TouchEvent('x'));
} catch (_) {}
return has;
})();

/**
* Returns the (x,y) coordinates representing the middle of a node.
Expand Down Expand Up @@ -70,7 +78,7 @@
clientY: xy.y
};

return window.Touch ? new window.Touch(touchInit) : touchInit;
return HAS_NEW_TOUCH ? new window.Touch(touchInit) : touchInit;
});
}

Expand All @@ -94,7 +102,7 @@
};
var event;

if (window.TouchEvent) {
if (HAS_NEW_TOUCH) {
touchEventInit.bubbles = true;
touchEventInit.cancelable = true;
event = new TouchEvent(type, touchEventInit);
Expand Down

0 comments on commit e097890

Please sign in to comment.