llh9743 发表于 2020-7-10 15:09:48

停止滚动无效没怎么办

我的代码是这样的
<style>
.swiper-container {
    width: 100%;
    height: 50%;
}
.swiper-slide {
    text-align: center;
    font-size: 18px;
    background: #fff;

    /* Center slide text vertically */
    display: -webkit-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-box-align: center;
    -ms-flex-align: center;
    -webkit-align-items: center;
    align-items: center;
}
.swiper-wrapper{
    transition-timing-function: linear !important;
}
</style>


var mySwiper = new Swiper ('.swiper-container', {
          loop: true,
          slidesPerView: 4,
          speed: 15000,//匀速时间
          autoplay: {
            delay: 0,
            stopOnLastSlide: false,
            disableOnInteraction: false,
          }
      });
      $('.swiper_container').mouseenter(function () {
          mySwiper.autoplay.stop();
      });
      // 鼠标移出开始自动滚动
      

$('.swiper_container').mouseleave(function () {
          mySwiper.autoplay.start();
      })这样可以有跑马灯的效果,但是stop无效了,哪里出了问题呢?

llh9743 发表于 2020-7-10 15:15:25

      改成这样也不行
$('.swiper-wrapper').mouseenter(function () {
          mySwiper.autoplay.stop();
          console.log(mySwiper.animating)//true
      });
      // 鼠标移出开始自动滚动
      $('.swiper-wrapper').mouseleave(function () {
          mySwiper.autoplay.start();
      })
页: [1]
查看完整版本: 停止滚动无效没怎么办