代码如下。
$(document).ready(function(){
$(".owl-carousel").owlCarousel({
items: 1,
loop: true,autoplay: true,
autoplayTimeout: 5000,
autoplayHoverPause: true,nav: true
});
$(".owl-item").click(function(){
$(".owl-stage").trigger('stop.autoplay.owl');
$(this).toggleClass('active');
});
});
任何帮助将不胜感激。
答案 0 :(得分:0)
您可以通过以下方式保存轮播状态:
let isBlocked = false;
const owl = $(".owl-carousel")
owl.owlCarousel({
items: 1,
loop: true,
autoplay: true,
autoplayTimeout: 5000,
autoplayHoverPause: true,
nav: true
});
$(".owl-item").click(function(){
// trigger which event should be fired
if(isBlocked) {
owl.trigger('stop.autoplay.owl');
else {
owl.trigger('play.autoplay.owl', [1000])
}
$(this).toggleClass('active');
isBlocked = !isBlocked
});