3

https://codesandbox.io/s/l79vn4rowq

When deleting items, I am not reinitializing the cellMeasurerCache, as I already have the dimensions of each item. By doing so, the upper and lower bound for populating position cache is not set as the CellMeasurer doesn't invoke invalidateCellSizeAfterRender if the dimensions are already present in the cache.

      //hack to set a range for populating position cache
      masonryInstance.invalidateCellSizeAfterRender({ rowIndex: 0 });
      masonryInstance.invalidateCellSizeAfterRender({
        rowIndex: batchSize - 1
      });

      //populate position cache
      masonryInstance.recomputeCellPositions();

I had to use the hack method invalidateCellSizeAfterRender for setting the upper and lower bounds for populating position cache. Is there a better way to do this?

  • 1
    It's been a long time since I've worked with the `Masonry` component. What you're describing sounds like it might be a bug in `Masonry`. All that I would expect you to need to do is call `masonryInstance.clearCellPositions()` after updating your position cache, but it doesn't look like that's sufficient. – bvaughn Jul 26 '18 at 14:58

0 Answers0