YIZHUANG / react-multi-carousel

A lightweight production-ready Carousel that rocks supports multiple items and server-side rendering with no dependency. Bundle size 2kb.
MIT License
1.3k stars 292 forks source link

beforeChange does not fire when dragging starts #237

Closed ishields closed 3 years ago

ishields commented 3 years ago

First off I really love this library! Really well done!

So I've uncovered what I think is a bug in which when you set the beforeChange callback it does not fire when dragging starts but rather when the user stops dragging and the slide starts (final position is set). When tracking the "isMoving" variable as is done in this example, https://github.com/YIZHUANG/react-multi-carousel#combine-beforechange-and-nextchange-real-usage, you can't really trust that "isMoving" value is correct because it's only true for a small time after the user lets go of the drag. In my use case I'd like to render an icon when the drag is occurring however that can't be done because this beforeChange event isn't equivalent to drag start. I did find this issue and it seems to indicate the beforeChange should behave this way.

https://github.com/YIZHUANG/react-multi-carousel/issues/60

Any help on this issue would be greatly appreciated!

YIZHUANG commented 3 years ago

You can do this by setting an event listener using the className you pass to the Carousel