How to make play.js slideshow

I have a slide show in which I would like to automatically play and cycle. I found fragments that allow me to set the global duration of the slides and use the impress.next () function with setInterval () to move forward, but then I lose the ability to have different durations for each slide.

+6
source share
1 answer

I am happy to share my decision. If you see a place for improvement, feel free to. Hope 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> 
+26
source

Source: https://habr.com/ru/post/921517/


All Articles