I'm trying to start the slider playing immediately, but i can't get it to work. I've tried with and without onFirstInit callback.
var defaultData = {
mode: 'horizontal',
loop: true,
slidesPerView: 2,
roundLengths: true,
autoPlay:2000,
keyboardControl: true,
onFirstInit:function(swiper)
{
swiper.startAutoplay();
},
onInit: function (swiper) {
var num = ($(window).width() < 800) ? 2 : 4;
swiper.params.slidesPerView = num;
}
};
Also, unrelated, I've noticed that onInit is fired on every window resize event. You might want to optionally debounce that.
You need to call .swipeNext right after initialization. And yes, onInit called with every window resize, otherwise you may ise onFirstInit
Changed to:
onFirstInit:function(swiper)
{
swiper.swipeNext();
},
And it's not working. It just moves one slide and stops.
How to start a slideshow?
Btw startAutoplay method name is so misleading.
Try to call .swipeNext(true)
nope, it still moves only the first slide and stops.
try different combinations, try NOT to put it inside of any callback, add it after you init swiper
Where should I put it , when I have to wait for the slider to be initialized before calling methods on it?
setTimeout?
I've also noticed that you don't have and demos with the slideshow option.
var swiper = new Swiper(...., {autoplay: 5000});
swiper.swipeNext(true, true);
swiper.startAutoplay(); //just in case
I know this is old, but in case anyone else finds themselves here. Change "autoPlay" to "autoplay" in the parameters, and it should fix the issue.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
I know this is old, but in case anyone else finds themselves here. Change "autoPlay" to "autoplay" in the parameters, and it should fix the issue.