1

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

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 Sierra

完整的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();
});
4

1 回答 1

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(); });

于 2016-11-28T15:14:12.817 回答