期间,jQuery Mobile的垂直滚动swipeleft / swiperight触发 [英] swipeleft/swiperight triggered during vertical scroll in jquery mobile

查看:193
本文介绍了期间,jQuery Mobile的垂直滚动swipeleft / swiperight触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是,swipeleft / swiperight事件被触发时,我想垂直滚动。

Problem is that swipeleft/swiperight event is trigger when i want vertical scroll.

我们正在使用jQuery Mobile的版本1.1.0和jQuery 1.7.1。

we are using jquery mobile 1.1.0 version and jquery 1.7.1.

和code是:

 $(document).delegate('#quizResumePage', 'swipeleft swiperight', function (event) {
   event.stopImmediatePropagation();
    if (event.type == 'swipeleft') {
       $('#btnnext').trigger('click');
    }  else  if (event.type == 'swiperight')  {
       $('#btnprevious').trigger('click');
    }
   event.preventDefault();
});

那么,为什么刷卡事件触发时,我想scorll页面??

Then why swipe event trigger when i want to scorll the page??

这个问题是发生在三星galaxy的Andr​​oid 2.3.5 ...

This problem is occur in the Samsung galaxy android 2.3.5...

任何一个可以帮我这个问题?

Can any one help me for this issue?

在此先感谢...

推荐答案

您可以控制​​的刷卡事件的工作改变下列对象的值

You can control how the swipe event works changing the values of the following object

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

把它放在你的code听挥笔之前。变化例如verticalDistanceThreshold至15和durationThreshold至500,这将有助于降低假阳性

place it on your code before listening to the swipes. Change for example the verticalDistanceThreshold to 15 and the durationThreshold to 500 that will help to reduce the false positive.

在另一边,在code你触发你的按钮的单击事件,而工作,更好的方法是直接调用执行下一/ previous行动的方法。

On the other side, in your code you're triggering the click event on your buttons, while that works, a better approach would be to call directly the method that executes next/previous actions.

祝你好运!

这篇关于期间,jQuery Mobile的垂直滚动swipeleft / swiperight触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆