views:

2087

answers:

4

How can you detect that a user swiped his finger in some direction over a web page with JavaScript?

I was wondering if there was one solution that would work for websites on both the iPhone and an Android phone.

+2  A: 

what i've used before is you have to detect the mousedown event, record it's x,y location (whichever is relevant) then detect the mouseup event, and subtract the two values.

contagious
+1  A: 

I'm trying to accomplish the same. I use jQtouch (javascript framework using jQuery) which provides a swipe event. It works fine on iPhone, but I'm still looking up for Android (Chrome Lite).

Savageman
A: 

I stumbled upon a site that provides a solution for the iPhone but has anyone been able to get it working on the Android phones? http://ajaxian.com/archives/swipe-flip-iphone

Marko
A: 

I created a demo, which works with mouse or finger, try it out, it has sample code for you to use as well

http://james.limsbros.com/2010/09/27/javascript-swipe-demo-works-both-with-finger-ipad-and-mouse-pc/

James Lin