metafizzy / flickity-docs

:memo: documentation for Flickity
28 stars 8 forks source link

autoplay after navigate #57

Closed bentalgad closed 6 years ago

bentalgad commented 6 years ago

Is it possible to have the autoplay resume, if the user pressed navigation and then didn't press anything for a few seconds?

desandro commented 6 years ago

See https://github.com/metafizzy/flickity/issues/429#issuecomment-411753543


autoPlay is designed to stop and stay stopped any time the user interacts with the carousel. This gives user control and does not take it away from the user. On mobile, there is no hover event so there is no way to detect when a cursor has exited the carousel.

That said, some developers still would like a way to resume autoPlay after being stopped for a period of time. If you wish to implement that behavior, you can do so with your own JS and the Flickity API.

Here is one solution that will always resume after being stopped for 3 seconds 🚨 even if the user has interacted with the carousel 🚨

// overwrite stopPlayer method
Flickity.prototype.stopPlayer = function() {
  this.player[ action ]();
  // always resume play after 3 seconds
  setTimeout( () => {
    this.player.play();
  }, 3000 )
};
bentalgad commented 6 years ago

Thanks. i see your point. and thanks for the snippet also. i will rethink and implement :)