如何让工作jquery在iPad上滚动“滑动”?

问题描述:

我有两个div,彼此相邻。除了click事件,我添加了一个swiperightswipeleft做一些事情。但是当我添加这些事件时,在iPad上滚动不再起作用。在个人电脑上没有问题!如何让工作jquery在iPad上滚动“滑动”?

有没有其他的方法可以使它们在iPad(触摸屏设备)上相互兼容?

谢谢!

+0

你能告诉你已经尝试了什么至今? –

实测值的溶液:

http://stephband.info/jquery.event.swipe/

滑动事件是建立在移动事件(stephband.info/jquery.event.move)的顶部上的薄包装。默认情况下,移动事件会覆盖原生滚动,因为他们假定您想要移动某些内容而不是滚动窗口。要重新启用滚动,请在movestart处理程序中调用e.preventDefault()。

在上面的例子中,我们希望能够swipeleft和swiperight,但上下滚动。里面一个movestart处理,手指的方向移动计算并防止该事件,如果发现它是向上,还是向下::

jQuery('.mydiv') 
 
.on('movestart', function(e) { 
 
    // If the movestart is heading off in an upwards or downwards 
 
    // direction, prevent it so that the browser scrolls normally. 
 
    if ((e.distX > e.distY && e.distX < -e.distY) || 
 
     (e.distX < e.distY && e.distX > -e.distY)) { 
 
    e.preventDefault(); 
 
    } 
 
});