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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With