DEV Community

Discussion on: [ TUTORIAL ] Create a simple Image Carousel with JavaScript

Collapse
 
saymon85 profile image
Nemanja Simeunovic • Edited

Hi,

I added one little functionality, when you click on previous button and first slide is active carousel crashes, so I add this code in prevSlide function

if (currentSlide > 0) {
currentSlide = (currentSlide - 1) % slides.length;
} else {
currentSlide = slides.length - 1;
}

Also added a setInterval for continuous repeat of slides.
Nice tutorial btw...
Cheers... :)

Collapse
 
albertomontalesi profile image
AlbertoM

Awesome, thanks