Skip to content

Swipe gesture in phonegap android

How swipe guesture to be implemented in phonegap android?

Answer

If you’re using jQuery mobile you can use the built in event swipe.

Documentation

E.g.:

$("#myContainer").on("swipe", function(event) {
    alert("I got swiped!");
});

If you’re using jQuery UI take a look at jQuery UI Touch Punch.

jQuery UI Touch Punch is a small hack that enables the use of touch events on sites using the jQuery UI user interface library.

Hammer.js is also a worthable mention here. It can be used in vanilla JavaScript as well as a jQuery plugin.

Hammer supports Tap, DoubleTap, Swipe, Drag, Pinch, and Rotate gestures. Each gesture triggers useful events and eventData.

If you don’t want to use a plugin take a look at the following.