SnafuBernd
SnafuBernd

Reputation: 271

Phonegap App: Swipe from the screen edge

I want to implement swipe gestures in my phonegap app. Hence, I looked into jquery mobile. However, if I did not overlook something, jquery mobile does not differentiate between swiping the screen or swiping from the screen egde. So if I want to implement some sliding in only if I swipe from the left screen edge (like a lot of google apps) it is not possible with jquery mobile. Is that correct? And if so, are there some usefull alternatives?

Upvotes: 1

Views: 2045

Answers (2)

Deepu
Deepu

Reputation: 1301

Try below in jqm 1.4+, worked for me, adjust the edge trim value accordingly, 50 was good for me

$( "div.ui-page" ).on( "swiperight", function( e ) {
    if ( e.swipestart.coords[0] <50) {
    // your logic 
    }
});

this is for x coordinate similarly you can get y from coords[1]

Upvotes: 1

fastr.de
fastr.de

Reputation: 1523

I think this isn't possible in jquery(-mobile) out of the box.

You can use hammer.js. It's a specialised library to do (multi-)touch detection in javascript. With the Event Data deltaX and the srcEvent position you can get where the touch starts and how long was the swiped distance.

Upvotes: 1

Related Questions