Skip to content

Commit

Permalink
fix: fix excessive rerendering of grid
Browse files Browse the repository at this point in the history
Fixes #698
  • Loading branch information
petyosi committed Jun 29, 2022
1 parent f3f4cdb commit ffceed4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/gridSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ const { round, ceil, floor, min, max } = Math
function buildItems(startIndex: number, endIndex: number) {
return Array.from({ length: endIndex - startIndex + 1 }).map((_, i) => ({ index: i + startIndex } as GridItem))
}

function gapComparator(prev: Gap, next: Gap) {
return prev && prev.column === next.column && prev.row === next.row
}
export const gridSystem = u.system(
([
{ overscan, visibleRange, listBoundary },
Expand Down Expand Up @@ -107,7 +111,7 @@ export const gridSystem = u.system(
u.combineLatest(
u.duc(totalCount),
visibleRange,
u.duc(gap),
u.duc(gap, gapComparator),
u.duc(itemDimensions, (prev, next) => prev && prev.width === next.width && prev.height === next.height)
),
u.withLatestFrom(viewportDimensions),
Expand Down

1 comment on commit ffceed4

@petyosi
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mihkeleidast FYI I had to add this after a bug report. Oversight in my code review.

Please sign in to comment.