基于滑动导航到页面

Navigate to page based on swipe

本文关键字:导航 于滑动      更新时间:2023-09-26

我有两个页面: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?
    }
});

您需要预取页面,然后在使用jquery时更改页面,因此您的代码如下所示:

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