2016-11-28 446 views
1

我使用了演示 https://owlcarousel2.github.io/OwlCarousel2/demos/mousewheel.html 只更改了下面的代码,因为它会在该示例中进行反向滚动。设置OwlCarousel2的滚动速度

if (e.deltaY>0) { 
owl.trigger('prev.owl'); 
} else { 
owl.trigger('next.owl'); 
} 

但它以非常大的速度滚动它。 如果每个舞台使用6个项目 - 没关系,但是如果你像每个舞台一样使用2或1个项目 - 它将滚动到数字10-11,而不是项目编号3或4.

我怎么能使滚动速度变慢?一次滚动滚动2-3个项目?

我使用Safari浏览器,Mac OSX版塞拉利昂

全JS代码:

var owl = jQuery('.owl-carousel'); 
owl.owlCarousel({ 
loop:false, 
// stagePadding: 100, 
slideBy:1, 
nav:true, 
margin:0, 
responsiveClass:true, 
responsive:{ 
0:{items:1}, 
600:{items:2,slideBy:2}, 
1024:{items:2,slideBy:2}, 
1366:{items:3,slideBy:3}, 
1920:{items:4,slideBy:4} 
} 
}); 

jQuery(".owl-prev").html(''); 
jQuery(".owl-next").html(''); 

owl.on('mousewheel', '.owl-stage', function (e) { 
if (e.deltaY>0) { 
owl.trigger('prev.owl.carousel', [1000]); 
} else { 
owl.trigger('next.owl.carousel', [1000]); 
} 
e.preventDefault(); 
}); 
+0

明白我想要什么 - 尝试调整窗口大小到最小(每个舞台一张幻灯片)并尝试用鼠标滚轮滚动猫头鹰传送带 https://owlcarousel2.github.io/OwlCarousel2/demos/mousewheel.html 您无法通过1张幻灯片或2进行滚动 - 它一次滚动7-11张幻灯片,它不会在幻灯片2或3上停止。 – illuzii

回答

0

我认为,你必须把prev.owl.carousel起来,例如:

owl.on('mousewheel', '.owl-stage', function (e) { 
    if (e.deltaY>0) { 
     owl.trigger('prev.owl.carousel', [5000]); 
    } else { 
     owl.trigger('next.owl.carousel', [5000]); 
    } 

e.preventDefault(); });

+0

不,它不会帮助 - 它不会停止在数字3 - 4它只是非常缓慢地滚动到数字10-11 :) – illuzii

+0

也有类似的问题,但我不是js编码器http://stackoverflow.com/questions/13000111/smooth-horizo​​ntal-scroll-bound-to-mousewheel? RQ = 1 – illuzii