Muuri: Changing widths of items and re-render the grid (question)

Created on 18 Jan 2018  路  4Comments  路  Source: haltu/muuri

Hi

Thanks for the good work, this is a great library!
I'm new to Muuri, and stuck in a situation where I need to dynamically change the width of some of the items, meaning different items have different width. Since they all have position: absolute, changing the width of one of them will make it overlap with the next.
My question: is there a good way to re-render the grid after a width of an item is changed, so no overlapping occurs, and the items are sorted without overflowing the container?

Thanks and regards

question

Most helpful comment

grid.refreshItems().layout(). And to optimize that further you can provide an array of items/elements as an argument for the refreshItems so that it only refreshes the items that you want to instead of refreshing all items.

All 4 comments

grid.refreshItems().layout(). And to optimize that further you can provide an array of items/elements as an argument for the refreshItems so that it only refreshes the items that you want to instead of refreshing all items.

Thanks a lot!
This solves the the re-rendering and sorting problem with overlapping.
I would like to ask another question if possible (yes, I know this is not a support forum, and sorry about this).

I'm initializing Muuri on dynamic elements that aren't existing on page load, and since the width change of items happens outside this scope, I'm loosing the context (Muuri instance) where the refresh (grid.refreshItems().layout()) should be fired. Is there any good approach to get the instance of the for dynamically generated elements?

Thanks again!

Hmmm... not quite following. Can you please share an example of this problem? And maybe it would be better that you create another ticket for this since it's a different issue. And close this one if the original problem was solved.

This issue seems to be resolved -> closing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bsherwoodofdaptiv picture bsherwoodofdaptiv  路  4Comments

osamamaruf picture osamamaruf  路  4Comments

niklasramo picture niklasramo  路  4Comments

qq164654109 picture qq164654109  路  5Comments

who519 picture who519  路  7Comments