JQuery Mobile - 改变taphold灵敏度

dan*_*dan 4 mobile jquery

我在Android上开发的JQuery移动应用程序有问题.

通常,当我只想滚动一个项目列表时,即使在我触摸的项目上也会触发.

这对我的用户来说非常令人沮丧.

我能做些什么呢?

我可以改变taphold事件的灵敏度吗?

很遗憾,我在谷歌上找不到任何东西.

谢谢,

Ale*_*ejo 7

在jQuery-mobile 1.1.*中,他们添加了更方便的方法来配置触摸事件:http://jquerymobile.com/demos/1.1.1/docs/api/events.html

对于taphold,您可以通过为其指定值来更改触发事件之前应该持续的时间$.event.special.tap.tapholdThreshold.

在导入JQM之前,但在导入jQuery之后,应在mobileinit事件中设置此值.例如,我做了以下操作以避免滑动和taphold事件之间的任何重叠:

<script type="text/javascript" src="/Scripts/jquery.min.js"></script>
<!-- JQM default options must be set after jQuery and before jQuery-mobile -->
<script type="text/javascript">
    $(document).bind("mobileinit", function () {
        $.event.special.tap.tapholdThreshold = 1000,
        $.event.special.swipe.durationThreshold = 999;
    });
</script>
<script type="text/javascript" src="/Scripts/jquery.mobile-1.1.0.js"></script>
Run Code Online (Sandbox Code Playgroud)