窗口调整大小已停止,Swiper自动播放

时间:2019-06-27 09:52:07

标签: javascript swiper

我正在使用带有自动播放参数的Swiper 4.5.0,并将对其进行响应性测试,但会发现问题,当窗口大小调整后,Swiper自动播放将无法像以前那样工作,并且将停止。

Jsfiddle示例:https://jsfiddle.net/1rytecaw

var mySwiper = new Swiper('.swiper-container', {
  speed: 3000,
  slidesPerView: 5,
  loop: true,
  allowTouchMove: false,
  simulateTouch: false,
  autoplay: {
    delay: 2000,
  },
})
<link href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/css/swiper.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.5.0/js/swiper.min.js"></script>

<!-- Slider main container -->
<div class="swiper-container">
  <!-- Additional required wrapper -->
  <div class="swiper-wrapper">
    <!-- Slides -->
    <div class="swiper-slide">Slide 1</div>
    <div class="swiper-slide">Slide 2</div>
    <div class="swiper-slide">Slide 3</div>
    <div class="swiper-slide">Slide 4</div>
    <div class="swiper-slide">Slide 5</div>
    <div class="swiper-slide">Slide 6</div>
    <div class="swiper-slide">Slide 7</div>
    <div class="swiper-slide">Slide 8</div>
  </div>
</div>

0 个答案:

没有答案