期间,jQuery Mobile的垂直滚动swipeleft / swiperight触发Mobile、jQuery、swiperight、swipeleft

2023-09-06 00:21:22 作者:安于命°

问题是,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.

祝你好运!