desandro / masonry

:love_hotel: Cascading grid layout plugin
https://masonry.desandro.com
16.28k stars 2.11k forks source link

masonry.reloadItems() not laying out new grid-items #1138

Closed Swimburger closed 3 years ago

Swimburger commented 3 years ago

I'm using a framework to render my HTML and I don't have sufficient control to use the append/prepend or appended/prepended functions. So I'm using reloadItems, but it doesn't lay out the items. The grid-items have their style updated with 'position: absolute', but not top/left styling.

Here's the issue replicated in CodePen: https://codepen.io/swimburger/pen/BaKjKPG The test case creates a new grid-item every second and call reloadItems.

danylobilokha commented 3 years ago

@Swimburger try

 masonry.reloadItems();
 masonry.layout();
Swimburger commented 3 years ago

That does layout the items after reload. Can't believe it was this obvious. When I did this in AngularJS a looong time ago, reloadItems was all you needed I think.

Thank you @danylobilokha.