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

标签 jquery jquery-mobile swipe

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

这里是我正在谈论的代码:

$('.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(默认值:30px) – 滑动水平位移必须大于此值。

  • $.event.special.swipe.verticalDistanceThreshold(默认值:75px) – 滑动垂直位移必须小于此值。

这必须在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

关于jquery - 调整jquery mobile中滑动事件的距离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16332625/

相关文章:

javascript - 阅读更多脚本和并排 div 无法正常协同工作

javascript - phonegap - 动态添加 javascript

html - Logo 在 Mozilla 的标题中掉落

android - 如何获取cardView item在recyclerView中的位置?

jquery - 在 Django 模板变量中链接 @username

javascript - jQuery - 从另一个页面加载内容 - 仅一次

javascript - 当用户滚动到特定元素的末尾时如何运行 jQuery 代码?

javascript - Jquery Mobile 对话框关闭无法正常工作

jquery - AngularJs 为 ng-swipe 添加动画

java - 无法解析方法 'setOnRefreshListener(anonymous android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener)'