How to make autoplay of the Swiper slider start only after the slider enters viewport?

Goran Tesic picture Goran Tesic · Mar 2, 2017 · Viewed 21k times · Source

I'm using this code to initialize swiper slider.

var mySwiper = new Swiper ('.swiper-container', {
    // Optional parameters
    pagination: '.swiper-pagination',
    paginationClickable: true,
    nextButton: '.swiper-button-next',
    prevButton: '.swiper-button-prev',
    spaceBetween: 0,
    parallax: true,
    autoplay: 5000,
    speed: 800,
    autoplayDisableOnInteraction: false
}) 

Since the slider is positioned inside the fourth section of the page and is visible only after the page is scrolled down, I would like to make the autoplay start only after the slider enters the viewport. Is there a way to do this?

Answer

user10488386 picture user10488386 · Oct 11, 2018
var mySwiper = new Swiper('.swiper-container', {
   autoplay: {
    delay: 5000,
  },

});