Skip to content

Commit 194261a

Browse files
committed
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
1 parent 6611805 commit 194261a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Chart.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ window.Chart = function(context){
852852
}
853853
}
854854

855-
if (window.Touch) {
855+
if (is_touch_device()) {
856856
context.canvas.ontouchstart = function(e) {
857857
e.offsetX = e.targetTouches[0].clientX - position.x;
858858
e.offsetY = e.targetTouches[0].clientY - position.y;
@@ -1508,4 +1508,9 @@ window.Chart = function(context){
15081508
// Provide some basic currying to the user
15091509
return data ? fn( data ) : fn;
15101510
};
1511+
1512+
function is_touch_device() {
1513+
return !!('ontouchstart' in window) // works on most browsers
1514+
|| !!('onmsgesturechange' in window); // works on ie10
1515+
};
15111516
}

0 commit comments

Comments
 (0)