haltu / muuri

Infinite responsive, sortable, filterable and draggable layouts
https://muuri.dev
MIT License
10.77k stars 643 forks source link

Retrieve the position of hidden grid items in custom layout function #555

Open romanstetsyk opened 1 year ago

romanstetsyk commented 1 year ago

First of all, thanks for all your hard work!

I'm trying to create a custom layout function (of type LayoutFunction) but having trouble retrieving the position of items before they were hidden. Please take a look at the following example:

  1. A grid has three visible items. My layout function receives an array of them (type Item[] as its third argument) and places them according to the function's logic.
  2. I hide one item. The layout function is invoked. The array of items has only two items.
  3. Now, I show the hidden item. The array of three items is passed as an argument to the layout function. But the previously hidden item has a position {left: 0, top: 0} for some reason.

My question is, how do I place it where it was before hiding? Could you show an example of a custom layout besides the one in the documentation?