metafizzy / flickity

:leaves: Touch, responsive, flickable carousels
https://flickity.metafizzy.co
7.53k stars 603 forks source link

Flickity `settle` event not called for index 0 (1st slide) #1232

Closed PROxZIMA closed 1 year ago

PROxZIMA commented 2 years ago

settle event not called for index 0 or for 1st slide

Test case: https://codepen.io/proxzima/pen/oNEQMVv

Expected behavior: settle event is said to be dispatched when the slider is settled at its end position. I expect it to be triggered when 1st slide settles too. If it is required to perform an action when a slides comes and completely settles in the view then as of now (Flickity v2.2) we have to call the action in on: { ready } (for the 1st slide) as well as in settle listener (for rest of the slides).

Screenshot

image

desandro commented 1 year ago

Thanks for reporting this issue. currently, settle will not be triggered after initialization. That's because settle is triggered after the settling animation ends. When initialized, there is no animation. Flickity jumps to initialIndex.

So - if you want to trigger something with settle and initializing Flickity, run the function both with in the settle event listener and after initializing Flickity.