如何通过拖动 idangero swiper 来防止滑动?
How to prevent swiping by dragging in idangero swiper?
我需要防止通过拖动(鼠标、手指)滑动,但在使用分页按钮和下一个或上一个按钮时保留它。
我是这样初始化的:
var pcSwiper = new Swiper('.swiper-container_pc', {
direction: 'horizontal',
slidesPerView: 'auto',
spaceBetween: 20,
nested: true
});
我发现 disableTouchControl
方法还禁用鼠标拖动(不仅是触摸拖动)。所以,这个方法的名称和描述有点不清楚,但它是有效的。
pcSwiper.disableTouchControl();
我需要防止通过拖动(鼠标、手指)滑动,但在使用分页按钮和下一个或上一个按钮时保留它。
我是这样初始化的:
var pcSwiper = new Swiper('.swiper-container_pc', {
direction: 'horizontal',
slidesPerView: 'auto',
spaceBetween: 20,
nested: true
});
我发现 disableTouchControl
方法还禁用鼠标拖动(不仅是触摸拖动)。所以,这个方法的名称和描述有点不清楚,但它是有效的。
pcSwiper.disableTouchControl();