davidjerleke / embla-carousel

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

Autoplay resumes when user changes tab #599

Closed matthewdixon closed 7 months ago

matthewdixon commented 8 months ago

Big fan of Embla here πŸ‘‹ Thanks so much for your fantastic work on this framework thus far, I love working with it!

Bug is related to

embla-carousel-autoplay

Embla Carousel version

7.1.0

Describe the bug

On the click of a button I am stopping autoplay with emblaApi.plugins().autoplay.stop(). Autoplay stops but only while the user remains within the current tab. When swapping tab then returning to the one with the previously stopped carousel, autoplay resumes.

CodeSandbox

https://codesandbox.io/s/tyh5r4

Steps to reproduce

  1. Change slide by clicking any of the buttons, ie. next/prev or dots
  2. Open a new browser tab or switch to one already open
  3. Return to tab with carousel, autoplay will restart

Expected behaviour

Autoplay to remain stopped when the user changes then returns to the tab.

Additional context

I don't believe this to be the intended functionality as when changing slide by clicking/dragging autoplay stops as expected and does not restart after changing tab.

davidjerleke commented 8 months ago

Hi @matthewdixon,

I will try to reproduce this when I get the chance. Thank you for a complete bug report with a CodeSandbox. This is as you already mentioned, not expected behavior.

Version 8.0.0 is just around the corner so I won’t be doing any bug fixes for v7 anymore. The bug fix will be released with v8. I hope you don’t have any objections migrating to v8.

I’ll let you know when I’ve investigated this further.

Best, David

matthewdixon commented 3 months ago

Hi @davidjerleke, apologies for the severely delayed response!! Great to hear you've rolled out a fix for v8, I've just had a play and can confirm this now works as expected πŸŽ‰

I had a look at the latest RC when you first replied but noticed the carousel wasn't as responsive so decided to come back to it when v8 had been released. Now it has and I've tested it, I still find it's not as responsive as v7 with what appears to be a slight lag between click/drag interactions and carousel movement. I love how snappy it was previously so this is a shame πŸ˜• Just wondering if this was an intentional change?

davidjerleke commented 3 months ago

I still find it's not as responsive as v7 with what appears to be a slight lag between click/drag interactions and carousel movement. I love how snappy it was previously so this is a shame πŸ˜• Just wondering if this was an intentional change?

Hi @matthewdixon,

I don't understand what you mean? I don't experience any lag at all. Embla v8 input is always responsive for me. For me, clicks happen instantly and drag interactions start instantly on pointer down and as soon as I start dragging the carousel reacts to it, even if it was in motion before the pointer down. But maybe I'm misunderstanding what you mean.

matthewdixon commented 1 month ago

Hi @davidjerleke, apologies for another outrageously late reply πŸ˜…

No you've understood correctly: it was only minimal but I definitely experienced a delay between interaction and response (I remember it being particularly noticeable on drag). I should have a chance to come back to this next week so I'll see if I can demo it to you somehow, might have to try capturing my screen if you're not seeing it your end as that suggests hardware might be a factor.

I'll report back!