I'm trying to create a simple image slideshow but it's not exactly working the way I want. When it cycles through all the images, I want it to immediately loop back to the first picture. But, there seems to be a delay before it loops back which isn't what i want. How can i fix this?
here's my codepen
var seconds = 2000;
var step = 0;
var limit = 2;
step = (step > limit) ? 0 : step + 1;
Change limit to zero:
limit = 0;
Even with 2 images as in your codepen example, you are starting your step (count) at 0, and also only resetting the slideshow when
step > limit, which requires 4 "rounds".
I've made an example of this behaviour here (see the counter): https://codepen.io/anon/pen/YERNrP