最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - My swiper with Swiper.js stop autoplay after slide it with finger, why? - Stack Overflow

programmeradmin8浏览0评论
var mySwiper = new Swiper('.myswiper', {
        autoplay: 3000,
        simulateTouch: true,
        loop: true,
        preloadImages: true,
        speed: 200,
        pagination: '.swiper-pagination'
    });

While this is my initial swiper, and when I drag it with mouse or touch it with finger and then slided it, my swiper stops auto playback, how to fix it?

var mySwiper = new Swiper('.myswiper', {
        autoplay: 3000,
        simulateTouch: true,
        loop: true,
        preloadImages: true,
        speed: 200,
        pagination: '.swiper-pagination'
    });

While this is my initial swiper, and when I drag it with mouse or touch it with finger and then slided it, my swiper stops auto playback, how to fix it?

Share Improve this question asked Aug 26, 2016 at 5:58 Alex LeeAlex Lee 1411 gold badge1 silver badge5 bronze badges 1
  • 1 can you share your html or Fiddle. – Sarath Kumar Commented Aug 26, 2016 at 6:00
Add a comment  | 

3 Answers 3

Reset to default 28

It's now 'disableOnInteraction'

var mySwiper = new Swiper ('.swiper-container', {
    direction: 'horizontal',
    loop: true,
    scrollbar: { el: '.swiper-scrollbar' },
    autoplay: {
        delay: 5000,
        disableOnInteraction: false
    }
});

The best solution is to find the answer in API of Swiper, like Autoplay Demo.

You should insert the swipe attribute below:

autoplayDisableOnInteraction: false

The instruction of this attribute:

Set to false and autoplay will not be disabled after user interactions (swipes), it will be restarted every time after interaction.

Use autoplay as define here

  autoplay={{
               delay: 2500,
               disableOnInteraction: false,
            }}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论