splide icon indicating copy to clipboard operation
splide copied to clipboard

Autoplay.pause() sets Autoplay.isPaused() as true but does not pause

Open StudioAl opened this issue 5 years ago • 3 comments

Checks

  • [X] Not a duplicate.
  • [X] Not a question, feature request, or anything other than a bug report directly related to Splide. Use Discussions for these topics: https://github.com/Splidejs/splide/discussions

Version

3.2.6

Description

I'm trying to programmatically pause and play a splide instance, but the the pause() command does not appear to be working correctly. Relevant code:

var Autoplay = splide.Components.Autoplay;

if(conditionistrue){
  Autoplay.play();
  console.log(Autoplay.isPaused());
} 
if(conditionisfalse){
  Autoplay.pause();
  console.log(Autoplay.isPaused());
}

The slideshow is paused, as expected, on load. When the condition is met, the slideshow plays as expected. But, after the slideshow plays once, when the condition is met to trigger Autoplay.pause(), Autoplay.isPaused() returns true, but the slideshow continues to play.

Reproduction Link

No response

Steps to Reproduce

  1. Programmatically play() slideshow
  2. Programmatically pause() slideshow

Expected Behaviour

When Autoplay.pause() is called, and Autoplay.isPaused() returns true, slideshow should stop playing.

StudioAl avatar Nov 11 '21 01:11 StudioAl

It looks working in 3.2.6: https://codesandbox.io/s/autoplay-08rdd

NaotoshiFujita avatar Nov 11 '21 02:11 NaotoshiFujita

Indeed; sorry for the false alarm. I believe it was the way I was managing it through IntersectionObserver was actually reinitializing it on every change.

StudioAl avatar Nov 12 '21 02:11 StudioAl

Hmm I am also getting this but outside of the intersection observer...

adamchipperfield avatar Oct 18 '22 16:10 adamchipperfield