0

我的导航标题中有一个小条形按钮,单击时会打开面板,但是如何制作它以便当我从应用程序中间向右滑动时,它会打开左侧面板?您可以在包括 Facebook 在内的许多本机应用程序上看到这一点。谢谢你的帮助!

4

3 回答 3

2

我认为这就是您想要的(您可能需要为您的滑动区域优化选择器) -

$('body').on('swiperight', function () {
    $('#defaultpanel').panel('open', '');
});

$('body').on('swipeleft', function () {
    $('#defaultpanel').panel('close');
});

jsFiddle 演示

于 2013-07-08T20:56:32.283 回答
1

Listen to swipe events swipeleft and swiperight and accordingly, open panels $('#id').panel('open').

Demo

$(document).on('swipeleft swiperight', function (e) {
  if (e.type == 'swiperight') {
    $('#left').panel('open');
  }
  if (e.type == 'swipeleft') {
    $('#right').panel('open');
  }
});
于 2013-07-08T21:49:27.457 回答
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" );
            }
        }
    }); });

这是文档:http: //view.jquerymobile.com/1.3.0/docs/examples/panels/panel-swipe-open.php#&ui-state=dialog

于 2013-11-08T12:45:04.803 回答