Skip to content

Commit

Permalink
stylistic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
madrobby committed Jul 14, 2012
1 parent d31d133 commit 249872d
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
// Zepto.js may be freely distributed under the MIT license.

;(function($){
var touch = {}, touchTimeout;
var tapTimeout, swipeTimeout;
var longTapDelay = 750, longTapTimeout
var touch = {},
touchTimeout, tapTimeout, swipeTimeout,
longTapDelay = 750, longTapTimeout

function parentIfText(node){
function parentIfText(node) {
return 'tagName' in node ? node : node.parentNode
}

function swipeDirection(x1, x2, y1, y2){
function swipeDirection(x1, x2, y1, y2) {
var xDelta = Math.abs(x1 - x2), yDelta = Math.abs(y1 - y2)
return xDelta >= yDelta ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down')
}

function longTap(){
function longTap() {
longTapTimeout = null
if (touch.last) {
touch.el.trigger('longTap')
touch = {}
}
}

function cancelLongTap(){
function cancelLongTap() {
if (longTapTimeout) clearTimeout(longTapTimeout)
longTapTimeout = null
}
Expand Down Expand Up @@ -63,15 +63,16 @@

// swipe
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))

swipeTimeout = setTimeout(function() {
touch.el.trigger('swipe')
touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2)))
touch = {}
}, 0);
}, 0)

// normal tap
} else if ('last' in touch) {
else if ('last' in touch)

// delay by one tick so we can cancel the 'tap' event if 'scroll' fires
// ('tap' fires before 'scroll')
Expand All @@ -98,9 +99,8 @@
}, 250)
}

}, 0);
}, 0)

}
})
.bind('touchcancel', cancelAll)

Expand Down

0 comments on commit 249872d

Please sign in to comment.