Aleš Sýkora / January 8, 2023 / 4 comments
Swiper.js continuous autoplay (like marquee)
1 min read / Scripts, Swiper.js / Share on: Twitter, LinkedIn, Facebook
Post summary: Set Swiper.js move to work like marquee.
The autoplay of Swiper.js stops on each slide when moving. If you rather want to play like marquee and continue moving/sliding, then you just need to edit the CSS and Swiper config. Maybe it will be available in Swipers API in future, but currently (swiper 8.4.5) it is not.
Add a custom CSS:
.swiper-wrapper {
transition-timing-function: linear;
}
And in your swiper initialization function add these:
speed:5000,
autoplay: {
delay: 1,
disableOnInteraction: false,
}
And now, take a seat and enjoy a marquee effect! You can tune the speed of slider with speed value.
Fuel my passion for writing with a beer🍺
Your support not only makes me drunk but also greatly motivates me to continue creating content that helps. Cheers to more discoveries and shared success. 🍻
zahid
Great!
Adam Darby
I’ve found this useful, but the slider tends to stutter. If enable “cssMode” then the stuttering stops, but then I don’t have freemode. Have you been able to figure out any way to have the best of both worlds?
Aleš Sýkora
Good! :)
Aleš Sýkora
Hello Adam, I am not sure why it stutter for you. Mine works fine. Maybe it depends on browser?… Can you share the URL? look at mine here: https://www.pixbot.cz/ in my browser (firefox for developers and MS Edge) it’s completely fine :/