2013-07-08 53 views
0

我的導航標題中有一個小按鈕,點擊時會打開面板,但是如何製作它以便當我從應用程序中間向右滑動時,它會打開左面板?你可以在包括Facebook在內的許多本地應用中看到這個。謝謝你的幫助!中間滑動以使用jQuery Mobile打開面板?

回答

2

我想這是你想要的東西(你可能要優化您的選擇您的刷卡區) -

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

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

jsFiddle Demo

1

聽刷卡事件swipeleftswiperight,因此,開面板$('#id').panel('open')

Demo

$(document).on('swipeleft swiperight', function (e) { 
    if (e.type == 'swiperight') { 
    $('#left').panel('open'); 
    } 
    if (e.type == 'swipeleft') { 
    $('#right').panel('open'); 
    } 
}); 
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