Autoplay timer keeps running, even when viewport is inactive
See original GitHub issueBug is related to
- embla-carousel (core package)
- embla-carousel-react
- embla-carousel-autoplay
- embla-carousel-docs (documentation website)
Embla Carousel version
- embla-carousel-autoplay: v6.0.2
- embla-carousel-react: v6.0.2
Describe the bug
The bug seems to cause two problems.
Rushing through slides on reactivation of viewport
After having the carousel with autoplay in an inactive viewport (tab which is not displayed) and activating it again (coming back to the tab) after a while (10mins for example), you can see how the carousel rushes through several slides until it catches up with the timer.
https://user-images.githubusercontent.com/1105080/149907898-f7a3bdf0-038c-4362-9a4b-f6b36fc98dd2.mp4
Carousel disappears entirely
When leaving the carousel with autoplay for even longer in the background, the carousel will disappear. The reason for this is that the transform
style on the carousel container has such a high negative value to move in in the x axis, that some browsers (Firefox especially) refuses to render the whole <div>
.
CodeSandbox
Steps to reproduce
- Open CodeSandbox mentioned above
- Leave the tab for some time in the background
- Come back to the tab and see the carousel rushing through the slides for a while
Expected behavior
- The timer should be stopped, when the carousel is inactive.
Additional context
Problem observed with
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
How to play audio in REACT app while browser tab is inactive?
The timer runs in a component built with reacts bootstrap modal component. If the browser tab in which the app is running is...
Read more >Autoplay policy in Chrome - Chrome Developers
Chrome's autoplay policies are simple: Muted autoplay is always allowed. Autoplay with sound is allowed if: The user has interacted with the ...
Read more >Fully Kiosk Browser & App Lockdown Help
Fully Kiosk app will help you to run the selected websites or apps in the kiosk mode. ... Auto reload on idle, on...
Read more >Implementing UAAG 2.0 - W3C
Note: Platform conventions will dictate whether or not keyboard focus in an inactive viewport is visually indicated by an inactive cursor.
Read more >Safari Technology Preview Release Notes - Apple Developer
Changed to keep MediaKeySystemAccess alive in a createMediaKeys() async task ... in a muted video element outside the viewport (251596@main); Fixed autoplay ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @openscript,
This problem should be fixed in v6.1.1. Please try it out and let me know if it solves the problem.
Best, David
Hi David @davidjerleke
Thank you so much for the quick fix. It solves the problem 😃
Robin