From 194261ac579a257ad97a3838777afe4487b22d84 Mon Sep 17 00:00:00 2001 From: Jamie Davidson Date: Sat, 24 Aug 2013 17:50:52 -0400 Subject: [PATCH] Chrome added window.Touch to newest release, so events stopped firing. Added an alternative way to determine if the current device was a touch screen --- Chart.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Chart.js b/Chart.js index a5be9a74aff..b5981bd756a 100755 --- a/Chart.js +++ b/Chart.js @@ -852,7 +852,7 @@ window.Chart = function(context){ } } - if (window.Touch) { + if (is_touch_device()) { context.canvas.ontouchstart = function(e) { e.offsetX = e.targetTouches[0].clientX - position.x; e.offsetY = e.targetTouches[0].clientY - position.y; @@ -1508,4 +1508,9 @@ window.Chart = function(context){ // Provide some basic currying to the user return data ? fn( data ) : fn; }; + + function is_touch_device() { + return !!('ontouchstart' in window) // works on most browsers + || !!('onmsgesturechange' in window); // works on ie10 + }; } \ No newline at end of file