jQuery bxSlider 触摸已启用 - 禁用垂直触摸事件,因此只有水平触摸事件有效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14460057/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 13:35:32  来源:igfitidea点击:

bxSlider touch enabled - disable vertical touch events so only horizontal touch events work

jquerytouch-eventbxslider

提问by Joshc

I'm using probably one of my favourite jquery slider plugins: bxSlider

我可能正在使用我最喜欢的 jquery 滑块插件之一:bxSlider

http://bxslider.com/options#touchEnabled

http://bxslider.com/options#touchEnabled

Recently they've updated with some touch enabling for devices. This allows you to scroll your sliders via swiping.

最近他们更新了一些设备的触摸功能。这允许您通过滑动来滚动滑块。

But on my current project, I have a slideshow that takes up the entire width of my website, and when viewing on a device, as I scroll down with my finger, when I reach the the slideshow, I am unable to scroll down the page, and instead the slideshow scrolls left to right.

但是在我当前的项目中,我有一个幻灯片,它占据了我网站的整个宽度,在设备上查看时,当我用手指向下滚动时,当我到达幻灯片时,我无法向下滚动页面,而是幻灯片从左向右滚动。

So my question is, is it possible to disable the vertical touch events so it only works when the scroll is swiped horizontally.

所以我的问题是,是否可以禁用垂直触摸事件,以便它仅在水平滑动滚动条时才有效。

var winnerSlider = $('#slider').bxSlider({

});

I have a fiddle if anyone can help... http://jsfiddle.net/2Fcxw/10/

如果有人可以帮忙,我有一个小提琴... http://jsfiddle.net/2Fcxw/10/

Scan qr below to view fiddle on device.

扫描下面的 qr 以查看设备上的小提琴。

enter image description here

在此处输入图片说明

Thanks

谢谢

回答by Johnny

$('#slider').bxSlider({
touchEnabled:false
});

This should work.

这应该有效。

回答by MarthyM

var winnerSlider = $('#slider').bxSlider({
    preventDefaultSwipeY: false
});

preventDefaultSwipeYshould be exactly what you needed. http://bxslider.com/options#preventDefaultSwipeY

preventDefaultSwipeY应该正是您所需要的。 http://bxslider.com/options#preventDefaultSwipeY

It should be set by default now, so there's no need to declare it.

它现在应该是默认设置,所以不需要声明它。

Tried your fiddle and it seems to be working fine wit the current bxSlider (v4. 1. 2).

试过你的小提琴,它似乎在当前的 bxSlider (v4.1.2) 上运行良好。