Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate swipe distance in jQuery-mobile

I hope you are well today, I am trying to calculate the swipe distance (a touch gesture) on a mobile website, how would you work out how many pixels the user has swiped across the screen?

$('.cmButtons').live('swipeleft',function(){
    console.log("swiped left");
});
like image 487
Xavier Avatar asked Aug 03 '11 09:08

Xavier


1 Answers

I would suggest the excellent jQuery TouchSwipe Plugin by Matt Bryson: http://labs.skinkers.com/touchSwipe/.

It has touch & swipe events for 4 directions and 1 or 2 fingers. And it has SwipeStatus with which you can get swipe distance: http://labs.skinkers.com/touchSwipe/demo/Swipe_status.html

like image 92
Jasper Moelker Avatar answered Oct 01 '22 13:10

Jasper Moelker