如何在鼠标离开时停止swiper slide autoplay进入并开始自动播放?

时间:2016-11-08 19:45:54

标签: swiper

如何在鼠标离开时停止swiper slide autoplay并在鼠标离开时启动自动播放?我尝试过.stopAutoPlay()和.startAutoPlay()函数,但对我没用。

谢谢你,这是代码。

 var swiper = new Swiper('.swiper-container', {
    pagination: '.swiper-pagination',
    paginationClickable: true,
    nextButton: '.swiper-button-next',
    prevButton: '.swiper-button-prev',
    spaceBetween: 0,
    loop: true,
    effect: 'slide',
    longSwipes: true,
    autoplay:2000,
    autoplayDisableOnInteraction:true,
});


$(".swiper-container").mouseenter(function(){
    swiper.stopAutoPlay();
});

$(".swiper-container").mouseleave(function(){
    swiper.startAutoPlay();
});

1 个答案:

答案 0 :(得分:0)

检查swiper API文档,你应该使用mySwiper.startAutoplay(),字母“p”是小写的