Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 246
Goran Tesic Avatar asked Sep 20 '25 15:09

Goran Tesic


1 Answers

var mySwiper = new Swiper('.swiper-container', {
   autoplay: {
    delay: 5000,
  },

});
like image 179
user10488386 Avatar answered Sep 22 '25 06:09

user10488386



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!