jelgblad / angular2-masonry

https://github.com/desandro/masonry module for Angular2
101 stars 48 forks source link

Can't make component redraw new array in order. #49

Closed jasonburrows closed 7 years ago

jasonburrows commented 7 years ago

If I drive my masonry-brick elements with an ngFor call against an array, when I reload that array with a new item, it always pushes it to the bottom (appends). Note that I'm not pushing something onto the array - it is a new array obtained from a subscription. I have called masonry._msnry.reloadItems, which does nothing, and 'masonry.layoutwhich also does nothing. (I've also tried callingreloadItemsfollowed bylayout` which also does nothing).

If I reload the page, the items render in the correct order.

How do I force masonry to redraw using the new array's order like it does on initial load?

jasonburrows commented 7 years ago

...using setTimeout to call reloadItems and layout to ensure the view has been updated first works. Likely this isn't a bug, just not how I'd prefer it work (but it works fine).