davidjerleke / embla-carousel

A lightweight carousel library with fluid motion and great swipe precision.
https://www.embla-carousel.com
MIT License
5.37k stars 164 forks source link

[Bug]: Autoplay fast scroll when opened in a new tab #790

Closed mojtaba06 closed 2 months ago

mojtaba06 commented 3 months ago

Which variants of Embla Carousel are you using?

Steps to reproduce

The bug occurs when I open site on new tab without check it and after 30 seconds see the tab.

Expected Behavior

When I visit that tab after 30 seconds, the slides should not have a fast initial scroll and the speed should be according to the settings.

Additional Context

Hi, thank you for the useful carousel you developed, Please open the sandbox link in a new tab and visit it after 30 seconds. https://9xvhl9.csb.app Good luck to you

What browsers are you seeing the problem on?

No response

Version

No response

CodeSandbox

https://codesandbox.io/p/sandbox/embla-carousel-generator-react-9xvhl9?file=%2Fsrc%2Fjs%2Findex.tsx

Before submitting

sarussss commented 3 months ago

Hi @mojtaba06 I think this problem is because Embla's autoplay plugin listens to the visibilitychange event to optimize by turning off autoplay when the tab is not visible, so this is not necessarily a bug.

davidjerleke commented 3 months ago

@mojtaba06 thanks for your bug report.

I think I have a pretty good idea what's causing this. Will let you know when I've had the chance to look into it.

Best, David

mojtaba06 commented 3 months ago

Hi @sarussss, thank you for your comment. Good luck.

mojtaba06 commented 3 months ago

Hi @davidjerleke,

Thank you for looking into this matter.

Best regards, Mojtaba

davidjerleke commented 2 months ago

@mojtaba06 would you mind testing if you can reproduce the problem in this CodeSandbox?

mojtaba06 commented 2 months ago

@davidjerleke Sure, I've tested the Sandbox, and the issue has been resolved. Thank you and good luck.

davidjerleke commented 2 months ago

Released in v8.0.1.