[Help]: Is there a way to receive events or toggle classnames when a slide starts and completes its movement? #1093
-
SummaryI'd like to add a specific classname to slides when they start moving, and remove the classname when the movement is completed. Is there a way to implement this currently? I tried adding the classname on the
What I'm looking for is a way to perform some action at the moment a slide starts moving and when it finishes moving, for each individual slide movement. Thank you for providing such a great library! 👍 If applicable, which variants of Embla Carousel are relevant to this question?
Additional informationNo response CodeSandbox exampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @asdf99245, So try increasing your |
Beta Was this translation helpful? Give feedback.
-
@davidjerleke Thank you for answering 😃 So Here is the sample demo! I need to set the autoplay delay to a minimum of 1000ms, but I've noticed that the settle event only occurs from a 2000ms delay onwards. Additionally, I've observed that when moving with scrollTo outside of autoplay, it moves quickly and then autoplays again, causing the settle event not to occur. Also, it appears that the settle event doesn't happen immediately after the movement, but with a slight delay! Thank you 👍 |
Beta Was this translation helpful? Give feedback.
@asdf99245 you can use the select event when the carousel selects a new target (starts animating), and use the snippet to in the following discussion to add a settle threshold:
Regarding this:
This is expected. If you check the Autoplay example in the docs, you will see that you need to call the autoplay reset method when calling scrollTo to avoid this.