davidjerleke / embla-carousel

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

Autoplay jump parameter #357

Closed davidjerleke closed 2 years ago

davidjerleke commented 2 years ago

Feature request is related to

Is your feature request related to an issue?

There's no way to utilize the jump parameter that embla.scrollNext() and embla.scrollPrev() accepts because these are invoked internally in the autoplay plugin.

Describe the solution you'd like

Add a boolean jump option that determines the default behaviour - if transitions should jump or not.

const options = { loop: true }
const embla = EmblaCarousel(emblaNode, options, Autoplay({ jump: true }))

Also allow to override the default jump behaviour using the autoplay API:

const embla = EmblaCarousel(emblaNode, options, Autoplay({ jump: true })) // autoplay will jump when it starts here

embla.plugins().autoplay.play(false) // <-- override defaultJump and start animating

Additional context

Feel free to join the conversation if you have anything to add.

Thanks

Thanks @th-km for the idea 💡:

davidjerleke commented 2 years ago

Hi @th-km,

Here's an implementation of the jump option and the play(jump: boolean) method jump override parameter:

Let me know if it's working as expected and if this was what you had in mind.

Best, David

th-km commented 2 years ago

Hi @davidjerleke, Sorry for the late reply, I'm just back from a trip.

This is exactly what I need in a current project, and it works as expected. Thank you so much for doing this in such a short amount of time!

davidjerleke commented 2 years ago

Hi @th-km,

Sorry for the late reply, I'm just back from a trip.

Not a problem. We all have a life 😉.

I just released this feature with v7.0.2. Give it a go if you want and let me know if it works as expected. Additionally, if you have a moment, I would very much appreciate if you could check out the documentation additions and see if the explanations make sense to you or if you would like to amend something there:

Thanks and cheers!

Best, David

th-km commented 2 years ago

@davidjerleke Thanks! I'll give it a go and get back to you. I have 2-3 projects that could really benefit from this update. The explanation looks great to me 👍

th-km commented 2 years ago

@davidjerleke I updated two recent projects with the autoplay/jump parameter and everything went super well!

davidjerleke commented 2 years ago

Happy to hear that @th-km 👍🏻. Thanks for confirming. Enjoy! Closing this issue as resolved then.