jquery - 滑动功能无法使用适用于 Android 的 jquerymobile 和 PhoneGap

标签 jquery jquery-mobile cordova swipe

我是phonegap的新手。我正在使用phonegap for android在eclipse中创建应用程序。我在xml文件夹中添加了phonegap.jar和插件。我还添加了jquery库和phonegap1.1.0 js。我正在尝试实现滑动功能以将一个页面导航到另一个页面,但它不起作用。有人能告诉我如何解决这个问题吗?

我在我的事件中调用inex.html 这是我的index.html

<html>
    <head>
        <title>sample check</title>
        <link rel="stylesheet" href="www/jquery.mobile/jquery.mobile-1.0rc2.min.css" type="text/css" charset="utf-8" />

        <script type="text/javascript" src="js/fnswipe.js"></script>
        <script type="text/javascript" src="www/jquery.mobile/jquery-1.6.4.min"></script>
        <script type="text/javascript" src="www/jquery.mobile/jquery.mobile-1.0rc2.min.js"></script>
        <script type="text/javascript" charset="utf-8" src="phonegap-1.1.0.js"></script>
    </head>
    <body>
        <div data-role="page" id="home">  
            <div data-role="content"> 
                <p> 
                    <ul data-role="listview" data-inset="true" data-theme="c"> 
                        <li id="listitem">Swipe Right to smple check page</li> 
                    </ul> 
                </p> 
            </div> 
        </div> 
    </body>
</html>

这是我的 js 文件

$("#listitem").swiperight(function() { 
    $.mobile.changePage("file:///android_asset/www/samplecheck.html"); 
}); 

感谢您的帮助

最佳答案

我遇到了同样的问题,除 Android 外,所有滑动事件均有效。为了解决这个问题,我必须为滑动事件设置阈值。您可以在 JS 文件中调用滑动事件之前设置它们。为了获得最佳结果,我将其设置为:

$.event.special.swipe.scrollSupressionThreshold = 10; // More than this horizontal displacement, and we will suppress scrolling.
$.event.special.swipe.horizontalDistanceThreshold = 30; // Swipe horizontal displacement must be more than this.
$.event.special.swipe.durationThreshold = 500;  // More time than this, and it isn't a swipe.
$.event.special.swipe.verticalDistanceThreshold = 75; // Swipe vertical displacement must be less than this.

这个答案对我帮助很大:swipeleft/swiperight triggered during vertical scroll in jquery mobile

以及文档:Events -> Touch Events -> Swipe

希望这有帮助!!

关于jquery - 滑动功能无法使用适用于 Android 的 jquerymobile 和 PhoneGap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9003977/

相关文章:

jquery-mobile - jQuery Mobile 弹出内容高度超过窗口高度

iphone - iOS 上带有应答禁用功能的闹钟

javascript - 通过 AJAX 和 jQuery 使用 HTML5 文件上传

jquery - 在调用另一个函数之前执行一些函数

jquery - 如何在对话框中关闭 jQuery Dialog?

android - 用于 Web 开发的廉价 Android 设备

javascript - JQuery Datepicker - 根据当前时间设置 MinDate

javascript - 从循环中动态填充可折叠 DIV 列表

javascript - reCaptcha 在 cordova/phonegap 应用程序中的使用

javascript - iOS 设备上的 ionic 页面问题