导航到基于滑动的页面

时间:2014-09-06 19:44:55

标签: javascript jquery html gesture

我有两个页面:index.html和right.html。

需要什么样的代码才能通过水平滑动屏幕从index.html转到right.html?

我正在使用jQuery Mobile

$(function()
{
    $(document).on( "swipeleft", swipeleftHandler );

    function swipeleftHandler( event )
    {
        // What is the code that should come here?
        // And how can I design it so index.html slides to left 
        // and right.html comes to the middle?
    }
});

1 个答案:

答案 0 :(得分:0)

您需要预取页面,然后在使用jquery时更改页面,因此您的代码将是这样的:

    $(document).on("swipeleft", "#indexId", function() {
        $.mobile.loadPage("right.html");
        $.mobile.changePage("right.html", { transition: "slide" });
    });