Skip to content

Commit

Permalink
Chrome added window.Touch to newest release, so events stopped firing…
Browse files Browse the repository at this point in the history
…. Added an alternative way to determine if the current device was a touch screen
  • Loading branch information
jhdavids8 committed Aug 24, 2013
1 parent 6611805 commit 194261a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
};
}

1 comment on commit 194261a

@Wikunia
Copy link

@Wikunia Wikunia commented on 194261a Sep 4, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 thanks!

Please # to comment.