From 086336183a4aae0b38ece0083358e0e5341c78f1 Mon Sep 17 00:00:00 2001 From: Hunter Loftis Date: Sun, 29 Apr 2012 09:31:17 -0400 Subject: [PATCH] cancels swiping in the same direction as a scroll --- src/touch.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/touch.js b/src/touch.js index 4b4cfd65f..38e13a293 100644 --- a/src/touch.js +++ b/src/touch.js @@ -3,7 +3,8 @@ // Zepto.js may be freely distributed under the MIT license. ;(function($){ - var touch = {}, touchTimeout, tapTimeout + var touch = {}, touchTimeout; + var tapTimeout, swipeTimeout; var longTapDelay = 750, longTapTimeout function parentIfText(node){ @@ -31,6 +32,7 @@ function cancelAll() { if (touchTimeout) clearTimeout(touchTimeout) if (tapTimeout) clearTimeout(tapTimeout) + if (swipeTimeout) clearTimeout(swipeTimeout) if (longTapTimeout) clearTimeout(longTapTimeout) longTapTimeout = touchTimeout = null touch = {} @@ -64,9 +66,11 @@ // swipe } else if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) || (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30)) { - touch.el.trigger('swipe') && + swipeTimeout = setTimeout(function() { + touch.el.trigger('swipe') && touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2))) - touch = {} + touch = {} + }, 0); // normal tap } else if ('last' in touch) {