Skip to content

Commit

Permalink
fix(): address repetitive rendering of grid
Browse files Browse the repository at this point in the history
Fix #243
  • Loading branch information
petyosi committed Dec 22, 2020
1 parent 67a9fb9 commit 652eb3a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/gridSystem.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as u from '@virtuoso.dev/urx'
import { domIOSystem } from './domIOSystem'
import { sizeRangeSystem } from './sizeRangeSystem'
import { sizeRangeSystem, boundryComparator } from './sizeRangeSystem'
import { stateFlagsSystem } from './stateFlagsSystem'
import { IndexLocation, normalizeIndexLocation } from './scrollToIndexSystem'
import { scrollSeekSystem } from './scrollSeekSystem'
Expand Down Expand Up @@ -135,8 +135,9 @@ export const gridSystem = u.system(
u.combineLatest(viewportDimensions, itemDimensions, gridState),
u.map(([viewport, item, { items }]) => {
const { top, bottom } = gridLayout(viewport, item, items)
return [top, bottom]
})
return [top, bottom] as [number, number]
}),
u.distinctUntilChanged(boundryComparator)
),
listBoundary
)
Expand Down
2 changes: 1 addition & 1 deletion src/sizeRangeSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const NONE = 'none' as const
export type ListEnd = typeof TOP | typeof BOTTOM
export type ChangeDirection = typeof UP | typeof DOWN | typeof NONE

const boundryComparator = (prev: NumberTuple, current: NumberTuple) => prev && prev[0] === current[0] && prev[1] === current[1]
export const boundryComparator = (prev: NumberTuple, current: NumberTuple) => prev && prev[0] === current[0] && prev[1] === current[1]

export const getOverscan = (overscan: Overscan, end: ListEnd, direction: ScrollDirection) => {
if (typeof overscan === 'number') {
Expand Down

0 comments on commit 652eb3a

Please sign in to comment.