From 7d4f016146af956eaffed5d199fc6d71ce1f3fd3 Mon Sep 17 00:00:00 2001 From: Gobhi Theivendran Date: Sun, 21 Aug 2011 09:59:20 -0400 Subject: [PATCH 1/2] When there's a tap the swipe event is fired on Nokia Symbian and Playbook tablet devices (this should not be the case since this is just a tap and not a swipe). Instead of checking if x2 and y2 are > 0, just checking to see if they are defined fixes this issue. Also re-factored the code a bit by moving the delta comparison in the conditional check. This has been tested on Playbook, Nokia Symbian, iPad and iPhone devices. --- src/touch.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/touch.js b/src/touch.js index 982ba93bf..63de3a32d 100644 --- a/src/touch.js +++ b/src/touch.js @@ -43,10 +43,10 @@ if (touch.isDoubleTap) { $(touch.target).trigger('doubleTap'); touch = {}; - } else if (touch.x2 > 0 || touch.y2 > 0) { - (Math.abs(touch.x1 - touch.x2) > 30 || Math.abs(touch.y1 - touch.y2) > 30) && - $(touch.target).trigger('swipe') && - $(touch.target).trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2))); + } else if ( (touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) || + (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30) ) { + $(touch.target).trigger('swipe') && + $(touch.target).trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2))); touch.x1 = touch.x2 = touch.y1 = touch.y2 = touch.last = 0; } else if ('last' in touch) { touchTimeout = setTimeout(function(){ From b2e75d25e9ee729b18114b6a1055951eb3c75e8d Mon Sep 17 00:00:00 2001 From: Gobhi Theivendran Date: Sun, 21 Aug 2011 10:12:24 -0400 Subject: [PATCH 2/2] When there's a tap, the swipe event is fired on Nokia Symbian and Playbook tablet devices (this should not be the case since this is just a tap and not a swipe). It seems that there is a slight move when tap event is fired on these devices, so touch.x2 and touch.y2 get set. But because the delta comparison Math.abs(touch.x1 - touch.x2) > 30) and Math.abs(touch.y1 - touch.y2) > 30) are inside the conditional block that checks if touch.x2 or touch.y2 > 0, the last conditional else if ('last' in touch) is never reached. Moving the delta comparison in the conditional check fixes this issue. This has been tested on Playbook, Nokia Symbian, iPad and iPhone devices --- src/touch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/touch.js b/src/touch.js index 63de3a32d..06ee2effc 100644 --- a/src/touch.js +++ b/src/touch.js @@ -44,7 +44,7 @@ $(touch.target).trigger('doubleTap'); touch = {}; } else if ( (touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) || - (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30) ) { + (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30) ) { $(touch.target).trigger('swipe') && $(touch.target).trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2))); touch.x1 = touch.x2 = touch.y1 = touch.y2 = touch.last = 0;