I have a small bars button in my nav header that opens the panel when clicked, but how do I make it so that when I swipe to the right from the middle of the app, it opens the left panel? You can see this on many native apps including Facebook. Thanks for any help!
Asked
Active
Viewed 3,752 times
3 Answers
2
I think this is what you'll want (you may want to refine your selector for your swipe area) -
$('body').on('swiperight', function () {
$('#defaultpanel').panel('open', '');
});
$('body').on('swipeleft', function () {
$('#defaultpanel').panel('close');
});

Ross
- 3,335
- 1
- 19
- 18
1
Listen to swipe events swipeleft
and swiperight
and accordingly, open panels $('#id').panel('open')
.
$(document).on('swipeleft swiperight', function (e) {
if (e.type == 'swiperight') {
$('#left').panel('open');
}
if (e.type == 'swipeleft') {
$('#right').panel('open');
}
});

Omar
- 32,302
- 9
- 69
- 112
0
$( document ).on( "pageinit", "#demo-page", function() {
$( document ).on( "swipeleft swiperight", "#demo-page", function( e ) {
// We check if there is no open panel on the page because otherwise
// a swipe to close the left panel would also open the right panel (and v.v.).
// We do this by checking the data that the framework stores on the page element (panel: open).
if ( $.mobile.activePage.jqmData( "panel" ) !== "open" ) {
if ( e.type === "swipeleft" ) {
$( "#right-panel" ).panel( "open" );
} else if ( e.type === "swiperight" ) {
$( "#left-panel" ).panel( "open" );
}
}
}); });
here is the documentation: http://view.jquerymobile.com/1.3.0/docs/examples/panels/panel-swipe-open.php#&ui-state=dialog

Radu Turtoi
- 189
- 9