在jquery mobile中调整滑动事件的距离

是否可以调整触发滑动事件所需的距离,如果是这样,它是如何完成的?

这里的代码我在谈论:

$('.page2').bind('swiperight',function(event,ui){
    $.mobile.changePage(
        $('.page1'),{
          allowSamePageTransition: true,transition: 'slide',reverse: 'true',showLoadMsg: false,reloadPage: true,}
    );
    return false; 
});

解决方法

对的,这是可能的.

您需要修改这些属性

> $.event.special.swipe.horizo​​ntaldistanceThreshold(认值:30像素) – 刷卡水平位移必须比这个多.
> $.event.special.swipe.verticaldistanceThreshold(认:960×75像素) – 刷卡垂直位移必须小于这一点.

这必须在mobileinit事件期间完成,如下所示:

$(document).bind("mobileinit",function(){
    $.event.special.swipe.horizontaldistanceThreshold (default: 30px);
    $.event.special.swipe.verticaldistanceThreshold (default: 75px);
});

最后一件事.如果您从未使用过mobileinit,则必须在初始化jQuery mobile之前调用此事件,如下所示:

<script src="jquery.js"></script>
<script>
    $(document).bind("mobileinit",function(){
        $.event.special.swipe.horizontaldistanceThreshold (default: 30px);
        $.event.special.swipe.verticaldistanceThreshold (default: 75px);
    });
</script>
<script src="jquery-mobile.js"></script>

请查看官方文档here

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...