Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/riklomas/zepto into riklo…
Browse files Browse the repository at this point in the history
…mas-master

Conflicts:
	README.rdoc
	src/touch.js
  • Loading branch information
madrobby committed Dec 17, 2010
2 parents 7e10f96 + 1182eed commit 53cc4c7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
11 changes: 11 additions & 0 deletions README.rdoc
Expand Up @@ -134,6 +134,17 @@ Double-tapping:

Swiping (e.g. "delete" button when swiping over a list entry):
$('some selector').swipe(function(){ ... });
<<<<<<< HEAD
=======

Swiping left:
$('some selector').swipeLeft(function(){ ... });

Swiping right:
$('some selector').swipeRight(function(){ ... });

= Ajax:
>>>>>>> 1182eedd3d59aec75b173b8723428439382b1cfe

= Ajax

Expand Down
7 changes: 4 additions & 3 deletions src/touch.js
Expand Up @@ -20,7 +20,8 @@
$(touch.target).trigger('doubleTap');
touch = {};
} else if (touch.x2 > 0) {
Math.abs(touch.x1 - touch.x2) > 30 && $(touch.target).trigger('swipe');
Math.abs(touch.x1 - touch.x2) > 30 && $(touch.target).trigger('swipe') &&
$(touch.target).trigger('swipe' + (touch.x1 - touch.x2 > 0 ? 'Left' : 'Right'));
touch.x1 = touch.x2 = touch.last = 0;
} else if ('last' in touch) {
touchTimeout = setTimeout(function(){
Expand All @@ -32,7 +33,7 @@
}).bind('touchcancel', function(){ touch = {} });
});

['swipe', 'doubleTap', 'tap'].forEach(function(gesture){
$.fn[gesture] = function(callback){ return this.bind(gesture, callback) }
['swipe', 'swipeLeft', 'swipeRight', 'doubleTap', 'tap'].forEach(function(m){
$.fn[m] = function(callback){ return this.bind(m, callback) }
});
})(Zepto);
6 changes: 6 additions & 0 deletions test/touch_functional.html
Expand Up @@ -25,6 +25,12 @@ <h1>Zepto touch functional test</h1>
})
.swipe(function(){
$(this).append(' | swipe!');
})
.swipeLeft(function(){
$(this).append(' | swipe left!');
})
.swipeRight(function(){
$(this).append(' | swipe right!');
});
</script>
</body>
Expand Down
6 changes: 6 additions & 0 deletions test/touchcancel_functional.html
Expand Up @@ -27,6 +27,12 @@ <h1>Zepto touch functional test</h1>
})
.swipe(function(){
$(this).append(' | swipe!');
})
.swipeLeft(function(){
$(this).append(' | swipe left!');
})
.swipeRight(function(){
$(this).append(' | swipe right!');
});
</script>
</body>
Expand Down

0 comments on commit 53cc4c7

Please sign in to comment.