Skip to content

Conversation

@gabrielecirulli
Copy link
Contributor

I am working on a horizontal timeline that uses react-tiny-virtual-list to reduce the amount of items rendered at any one time. Clicking on an item on this timeline should center it horizontally. I noticed that when clicking on an item after scrolling, the item would not center.

This fixes instances where, right after scrolling, a change in the scrollToIndex prop will not actually scroll to the item at the passed index correctly. This is due to the componentDidUpdate method considering the previous state to actually be the next state and looking at scrollChangeReason on it, seeing the old scrollChangeReason caused by the user scrolling, thus not calling scrollTo to actually center the element.

…evState)

This fixes instances where, right after scrolling, a change in the
`scrollToIndex` prop will not actually scroll to the item at the passed
index correctly. This is due to the `componentDidUpdate` method
considering the previous state to actually be the next state and
looking at `scrollChangeReason` on it, seeing the old
`scrollChangeReason` caused by the user scrolling, thus not calling
`scrollTo` to actually center the element.
Copy link
Owner

@clauderic clauderic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh man, good catch 🙈

@clauderic clauderic merged commit caa304f into clauderic:master Oct 24, 2017
@clauderic
Copy link
Owner

Just published this change in 2.1.4, thanks again for your contribution 😄

@gabrielecirulli
Copy link
Contributor Author

Perfect, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants