eiriklv / react-masonry-component

A React.js component for using @desandro's Masonry
MIT License
1.44k stars 145 forks source link

Problem when the items change twice or more very quickly. #86

Closed janpe closed 7 years ago

janpe commented 7 years ago

If I the items change for example two times very quickly, the items sometimes fail to reorder when animations are used.

For example if I have a button that changes the props that make a rerender happen and the items transition to their new positions and I double click this button, problems occur pretty often.

If the latter click happens during the first animation then the items may get mispositioned leaving blank spaces or overlapping each other.

afram commented 7 years ago

Hi,

Does this button toggle some state, or is it for a single state? I ask because if it's the latter then React's diffing algorithm shouldn't force a re-render on the second click because the state wouldn't have changed.

janpe commented 7 years ago

Maybe it's easier understand if I explain the case in more detail. I have a view that has messages for one week in masonry items and I can use a control to jump between weeks and get messages for that week. So the state changes and I get a bunch of all new items. And when I do change the week when an animating of the masonry items is still ongoing then I sometimes get this problem.

afram commented 7 years ago

aha, so it's closer to the first scenario then. :-)

Does this issue still occur when you set the transitionDuration to 0?

janpe commented 7 years ago

No, all good with transitionDuration 0. That's also what I decided to do for now to avoid the problem.

afram commented 7 years ago

OK that's something at least.

It may be an issue with Masonry itself instead of this component. Have you been able to reproduce this issue with vanilla Masonry at all?

janpe commented 7 years ago

Yeah that's something I was thinking of as well. But I didn't have the time to try and reproduce this with vanilla Masonry so I decided to create an issue in this repository.

I can try this out with vanilla Masonry (and add issue to the Masonry repository if it occurs there as well) later but I'm just about to leave for a vacation for a week so I won't be able to test this before I get back in little over a week from now.

afram commented 7 years ago

Hi @janpe

I'm going to close this issue. Please feel free to reopen if needed :-)