I ask if a Phonegap application is able to recognize swipeLeft and SwipeRight related events in Javascript.
-
Are you using any kind of framework or plugin for swipe behavior? – Samuli Hakoniemi Dec 04 '12 at 11:08
-
i am using HTML5, Javascript, and css3 for making phonegap app in Android – Gaurav Dec 04 '12 at 12:38
-
possible duplicate of [Detect a finger swipe through JavaScript on the iPhone and Android](http://stackoverflow.com/questions/2264072/detect-a-finger-swipe-through-javascript-on-the-iphone-and-android) – givanse Apr 19 '14 at 17:12
5 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.

- 9,028
- 6
- 63
- 85
We use quo.js. It`s a lightweight framework to handle multi touch events and more.

- 3,693
- 2
- 16
- 25

- 3,505
- 6
- 59
- 114
-
Hi Dan thanks for your help it will working fine with the help of quo.js – Gaurav Dec 13 '12 at 04:52
-
Use this one its working in ios and android with phonegap.
$("#test").swipe( {
click:function(event, target) {
log("click from callback");
},
swipe:function(event, direction, distance, duration, fingerCount) {
log("swipe from callback");
},
swipeLeft:function(event, distance, duration, fingerCount) {
log("swipeLeft from callback");
},
swipeRight:function(event, distance, duration, fingerCount) {
log("swipeRight from callback");
},
swipeUp:function(event, distance, duration, fingerCount) {
log("swipeUp from callback");
},
swipeDown:function(event, distance, duration, fingerCount) {
log("swipeDown from callback");
},
swipeStatus:function(event, phase, direction, distance, duration, fingers) {
log("swipeStatus from callback");
},
pinchIn:function(event, direction, distance, duration, fingerCount, pinchZoom) {
log("pinchIn from callback");
},
pinchOut:function(event, direction, distance, duration, fingerCount, pinchZoom) {
log("pinchOut from callback");
},
pinchStatus:function(event, phase, direction, distance , duration , fingerCount, pinchZoom) {
log("pinchStatus from callback");
},
fingers:$.fn.swipe.fingers.ALL
});
-
What is this using though, I presume this is using JQuery mobile correct? Or is it using Zepto or? – Gurnard Jan 16 '14 at 08:49
-
these are all events and callback of TouchSwipe api 1) http://labs.rampinteractive.co.uk/touchSwipe/demos/Handlers_and_events.html – Ved Jan 16 '14 at 08:55
-
-
I didn't test in windows phone but it works in android and iphone, you can try it in windows phone bcoz it is jquery it work for me amazing in phonegap app. – Ved Jun 12 '15 at 13:02
Zepto has touch events for swipeLeft and swipeRight, and many others: http://zeptojs.com/#Touch%20events

- 4,687
- 3
- 28
- 40