Skip to content

Commit

Permalink
Merge pull request madrobby#421 from danjordan/zepto
Browse files Browse the repository at this point in the history
---

Im unsure whether longTap should fire when scrolling. To counteract this Ive cleared the longTap timeout if touchmove is detected.

Conflicts:
	src/touch.js
  • Loading branch information
madrobby committed Apr 5, 2012
2 parents a38473c + ea9759c commit d4bd9e6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
return xDelta >= yDelta ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down')
}

var longTapDelay = 750
var longTapDelay = 750, longTapTimeout

function longTap(){
longTapTimeout = null
if (touch.last && (Date.now() - touch.last >= longTapDelay)) {
touch.el.trigger('longTap')
touch = {}
Expand All @@ -31,8 +33,10 @@
touch.y1 = e.touches[0].pageY
if (delta > 0 && delta <= 250) touch.isDoubleTap = true
touch.last = now
setTimeout(longTap, longTapDelay)
longTapTimeout = setTimeout(longTap, longTapDelay)
}).bind('touchmove', function(e){
if (longTapTimeout) clearTimeout(longTapTimeout)
longTapTimeout = null
touch.x2 = e.touches[0].pageX
touch.y2 = e.touches[0].pageY
}).bind('touchend', function(e){
Expand Down

0 comments on commit d4bd9e6

Please sign in to comment.