Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phonegap: is it possible to detect swipeLeft and SwipeRight touch from Javascript?

I ask if a Phonegap application is able to recognize swipeLeft and SwipeRight related events in Javascript.

like image 842
Gaurav Avatar asked Dec 04 '12 10:12

Gaurav


2 Answers

Phonegap doesn't give you anymore touch events than you otherwise get with a normal mobile website. I.e. it's just wrapping a UIWebView (on iOS) or whatever the equivalent is on the other platforms.

Touch events in mobile browsers include touchstart, touchend, touchmove, etc.

There aren't any fancy swipe events, or double-tap events, or anything like that natively implemented in mobile browsers.

But you can simulate those more complicated events by using javascript in conjunction with the stock touchstart, touchend events etc.

Luckily you don't need to bother writing those events yourself because nearly every mobile framework has done that for you. Other people have mentioned some libraries that handle touch events.

Myself, I tend to use jQuery Mobile which has swipeleft and swiperight events, as well as others.

http://jquerymobile.com/demos/1.2.0/docs/api/events.html

You don't even have to use the full jQuery Mobile framework if you don't want to. You can just include their touch event handlers if you want.

like image 151
asgeo1 Avatar answered Oct 08 '22 00:10

asgeo1


We use quo.js. It`s a lightweight framework to handle multi touch events and more.

like image 44
最白目 Avatar answered Oct 07 '22 23:10

最白目