Skip to content

Commit

Permalink
Fix itemsPerRow calculation in CollectionView (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithmohan authored Oct 23, 2023
1 parent 4e73c81 commit 4b425e6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/Collection/CollectionView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ const CollectionView = ({ isSidebarOpen, mode, setGroupTotal, setTimelineSeries
const [gridContainerRef, gridContainerBounds] = useMeasure();

const [itemsPerRow, count] = useMemo(() => {
const tempItemsPerRow = Math.max(1, Math.floor((gridContainerBounds.width) / itemWidth));
const tempItemsPerRow = Math.max(1, Math.floor((gridContainerBounds.width + itemGap) / (itemWidth + itemGap)));
const tempCount = total === -1 ? 0 : Math.ceil(total / tempItemsPerRow);
return [tempItemsPerRow, tempCount];
}, [gridContainerBounds.width, itemWidth, total]);
}, [gridContainerBounds.width, itemGap, itemWidth, total]);

const virtualizer = useVirtualizer({
count,
Expand Down

0 comments on commit 4b425e6

Please sign in to comment.