Closed patrulea closed 4 years ago
Hi.
Please look into something like Intersection Observer. I have an article about the subject: https://pawelgrzybek.com/the-intersection-observer-api-explained/
API to detect if a tab / window is active or not that may be helpful is Page Visibility API: https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
Hopefully those references are helpful. Have a good day 🥑
My current Siema setup changes the slides automatically every 2 seconds, but stops when the user interacts with the carousel (either by sliding or by pressing the slide controls). It’s been working great. A live demo can be seen on my website.
Though, I’d like the autoplay only when the carousel is visible.
This is my current code:
I’m thinking this could be done by letting the interval run just when the
div.siema
is within the viewport; though, I know nothing about JavaScript and would be grateful if someone helped me out with this.