yaodingyd / react-flickity-component

A React.js component for using @desandro's Flickity
314 stars 51 forks source link

Carousel resets to first page after adding an item #104

Closed wcauchois closed 4 years ago

wcauchois commented 4 years ago

If I add an item to the set of children in my flickity carousel (using this library), and the user has scrolled to a later item, then the carousel resets to the first item (item 0).

Is there any workaround to ensure that the carousel remains on the cell that the user has selected, while adding new items?

Thanks!

yaodingyd commented 4 years ago

I'm assuming you are using reloadOnUpdate, which essentially reset flickity's state. You have to manually keep track of user's state and use flickity api to restore user's selection.

nelsondude commented 3 years ago

@wcauchois Do you recall your solution for this? I'm assuming reloadOnUpdate needs to be false but then what else is required?

benitodotcool commented 2 years ago

@wcauchois @nelsondude Do you guys manage to solve the problem? I have approximately the same problem: I have some global state in my application, and when a state is updated my Slider keep being reset to the initialIndex: 0 (which is the original index I want). Thanks 🤞🏻