gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 22:32:10 26 4
gpt4 key购买 nike

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

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

$('.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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com