Skip to content

Commit

Permalink
cancels swiping in the same direction as a scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterloftis authored and madrobby committed Jul 14, 2012
1 parent 1c3467a commit 0863361
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 0863361

Please sign in to comment.