From 82e41daeb0b8b61c5dc4c85e6fff9200a6e9620e Mon Sep 17 00:00:00 2001 From: Limon Monte Date: Mon, 9 Jan 2017 15:26:16 +0200 Subject: [PATCH] Fix touch support detecting --- mock-interactions.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mock-interactions.js b/mock-interactions.js index 6042405..6902ee8 100644 --- a/mock-interactions.js +++ b/mock-interactions.js @@ -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. @@ -70,7 +78,7 @@ clientY: xy.y }; - return window.Touch ? new window.Touch(touchInit) : touchInit; + return HAS_NEW_TOUCH ? new window.Touch(touchInit) : touchInit; }); } @@ -94,7 +102,7 @@ }; var event; - if (window.TouchEvent) { + if (HAS_NEW_TOUCH) { touchEventInit.bubbles = true; touchEventInit.cancelable = true; event = new TouchEvent(type, touchEventInit);