From 73673bd7895356565d991e8d61e1e29ea53aa054 Mon Sep 17 00:00:00 2001 From: Luis Leiva Date: Sun, 12 Nov 2017 20:03:52 +0100 Subject: [PATCH] Fixed multitouch events --- jquery.sketchable.js | 6 ++++-- sketchable.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/jquery.sketchable.js b/jquery.sketchable.js index b4beeb7..40146f8 100644 --- a/jquery.sketchable.js +++ b/jquery.sketchable.js @@ -408,8 +408,9 @@ */ function execTouchEvent(e, callback) { var elem = $(e.target), data = elem.data(namespace), options = data.options; - var touches = e.originalEvent.touches; if (options.multitouch) { + // Track all fingers. + var touches = e.originalEvent.changedTouches; for (var i = 0; i < touches.length; i++) { var touch = touches[i]; // Add the type of event to the touch object. @@ -417,7 +418,8 @@ callback(touch); } } else { - var touch = touches[0]; + // Track only the current finger. + var touch = e.originalEvent.touches[0]; // Add the type of event to the touch object. touch.type = e.type; callback(touch); diff --git a/sketchable.js b/sketchable.js index 317fc39..02d42b6 100644 --- a/sketchable.js +++ b/sketchable.js @@ -411,8 +411,9 @@ */ function execTouchEvent(e, callback) { var elem = e.target, data = dataBind(elem)[namespace], options = data.options; - var touches = e.touches; if (options.multitouch) { + // Track all fingers. + var touches = e.changedTouches; for (var i = 0; i < touches.length; i++) { var touch = touches[i]; // Add the type of event to the touch object. @@ -420,7 +421,8 @@ callback(touch); } } else { - var touch = touches[0]; + // Track only the current finger. + var touch = e.touches[0]; // Add the type of event to the touch object. touch.type = e.type; callback(touch);