I have a slideshow I'd like to auto play and loop continuously. I've found snippets that let me set a global slide duration and use impress.next() with a setInterval() call to move forward, but then I lose the ability to have different durations for each slide.
Asked
Active
Viewed 8,409 times
1 Answers
26
I'm happy to share my solution. If you see room for improvement don't be shy. Hopefully this helps someone out there.
<script>
var impress = impress();
impress.init();
document.addEventListener('impress:stepenter', function(e){
if (typeof timing !== 'undefined') clearInterval(timing);
var duration = (e.target.getAttribute('data-transition-duration') ? e.target.getAttribute('data-transition-duration') : 2000); // use the set duration or fallback to 2000ms
timing = setInterval(impress.next, duration);
});
</script>

creativetim
- 1,138
- 2
- 13
- 26
-
very helpful saved lots of time. +1 for this :) – Deep Sharma Jul 30 '13 at 11:15
-
1Thanks! This got me going in the right direction. However, I did run into some problems. Using custom data-transition-duration on multiple steps, it was hard to get the slideshow to slow down after using a short duration. For me, replacing setInterval(impress.next,duration) with setTimeout(impress.next, duration) would cause the slideshow to behave in the way I wanted it to. – SiPe May 07 '15 at 09:30