-
-
Notifications
You must be signed in to change notification settings - Fork 424
feat(virtual-core): add deferLaneAssignment option #1115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@tanstack/virtual-core': patch | ||
| --- | ||
|
|
||
| feat(virtual-core): add deferLaneAssignment option |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -346,6 +346,7 @@ export interface VirtualizerOptions< | |
| enabled?: boolean | ||
| isRtl?: boolean | ||
| useAnimationFrameWithResizeObserver?: boolean | ||
| deferLaneAssignment?: boolean | ||
| } | ||
|
|
||
| export class Virtualizer< | ||
|
|
@@ -446,6 +447,7 @@ export class Virtualizer< | |
| isRtl: false, | ||
| useScrollendEvent: false, | ||
| useAnimationFrameWithResizeObserver: false, | ||
| deferLaneAssignment: false, | ||
| ...opts, | ||
| } | ||
| } | ||
|
|
@@ -726,6 +728,10 @@ export class Virtualizer< | |
| let lane: number | ||
| let start: number | ||
|
|
||
| // Check if this item has been measured (for deferLaneAssignment mode) | ||
| const isMeasured = itemSizeCache.has(key) | ||
| const shouldDeferLane = this.options.deferLaneAssignment && !isMeasured | ||
|
|
||
|
Comment on lines
+731
to
+734
|
||
| if (cachedLane !== undefined && this.options.lanes > 1) { | ||
| // Use cached lane - O(1) lookup for previous item in same lane | ||
| lane = cachedLane | ||
|
|
@@ -750,8 +756,8 @@ export class Virtualizer< | |
| ? furthestMeasurement.lane | ||
| : i % this.options.lanes | ||
|
|
||
| // Cache the lane assignment | ||
| if (this.options.lanes > 1) { | ||
| // Cache the lane assignment (skip if deferring and not yet measured) | ||
| if (this.options.lanes > 1 && !shouldDeferLane) { | ||
| this.laneAssignments.set(i, lane) | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wording “size measured by
estimateSize” is inaccurate—estimateSizeprovides an estimate, not a measurement. Consider rephrasing to “size estimated byestimateSize” to avoid implying it’s based on DOM measurement.