From 8f9a13008c7c92e9ed9882571f89f829b03f067d Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 16 Nov 2016 23:05:02 +0100 Subject: [PATCH] touch/drag: implement a precision/speed factor based on the number of fingers in contact with the widget --- src/browser/js/jquery/jquery.drag.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/browser/js/jquery/jquery.drag.js b/src/browser/js/jquery/jquery.drag.js index 5e6d1321..a1e0a462 100644 --- a/src/browser/js/jquery/jquery.drag.js +++ b/src/browser/js/jquery/jquery.drag.js @@ -129,6 +129,7 @@ var oE = e.originalEvent + touches: for (i in oE.changedTouches) { if (isNaN(i)) continue @@ -148,6 +149,12 @@ touch.offsetX = touch.pageX-off.left touch.offsetY = touch.pageY-off.top + for (j in targets) { + if (targets[j][0].isSameNode(touch.target)) { + continue touches + } + } + targets[id].triggerHandler('draginit',[touch,e.originalEvent.traversing]) } @@ -167,22 +174,17 @@ if (isNaN(i)) continue - if (oE.targetTouches[j].target.length > 1) { - //"é" - } - - var touch = oE.changedTouches[i], - id = touch.identifier + id = touch.identifier, + speedFactor = oE.targetTouches.length == 1 ? 1 : Math.pow(2,oE.targetTouches.length) if (e.originalEvent.traversing) { targets[id] = $(document.elementFromPoint(touch.clientX, touch.clientY)) } - // touched[targets[id]] = touched[targets[id]]?touched[targets[id]]+1:1 - touch.speedX = touch.pageX - previousTouches[id].pageX - touch.speedY = touch.pageY - previousTouches[id].pageY + touch.speedX = (touch.pageX - previousTouches[id].pageX) / speedFactor + touch.speedY = (touch.pageY - previousTouches[id].pageY) / speedFactor touch.deltaX = touch.speedX + previousTouches[id].deltaX touch.deltaY = touch.speedY + previousTouches[id].deltaY