eiriklv / react-masonry-component

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

do not prepend if already reloading #130

Open kyrasteen opened 6 years ago

kyrasteen commented 6 years ago

Hello!

I really appreciate the work done for this component, so thank you!

I found a positioning issue with a particular use case I have. I am prepending items to the masonry layout while maintaining the position/index of some existing items. I am not using the 'stamp' option of masonry in order to still utilize the layout/positioning logic for the 'stuck' items.

Here is a simplified example of the issue: https://codesandbox.io/s/m5888np119

If you click 'prepend' you will see the positioning issue. The turquoise item should be kept in place. I would like the end result for the example to look like this after prepending one item: screen shot 2018-06-14 at 3 06 16 pm

If a child of the masonry layout has an image, I have seen the issue be resolved most of the time by the layout call in the images loaded callback, but not always.

Didn't see the need to prepend the new item(s) when items are already being reloaded before a layout call. Let me know what you think of the change. :)

afram commented 6 years ago

Thanks for the PR @kyrasteen :-) Will look this weekend when I get moment if that's ok

hutber commented 3 years ago

Possible the oldest approved PR I've seen in a very very long time :D @afram lol