feat(virtual): derive visibleCount and overscan from container size#13
Open
chiefcll wants to merge 1 commit into
Open
feat(virtual): derive visibleCount and overscan from container size#13chiefcll wants to merge 1 commit into
chiefcll wants to merge 1 commit into
Conversation
Removes displaySize, bufferSize, uniformSize, and factorScale props from VirtualRow / VirtualColumn. Visible count and buffer are now computed from container width/height and the first child's measured size on a single layout pass; the result is cached for the lifetime of the component (item size assumed uniform). A single probe item is rendered until measurement completes, then the full slice expands in. Container must have a measurable width (Row) or height (Column) on first layout. VirtualGrid is untouched. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
494bf14 to
dbd9595
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces
VirtualRow/VirtualColumnwith a version that derives window size from the rendered layout instead of asking the caller for it. The outer API is otherwise unchanged.Removed props (all auto-derived now):
displaySizefloor(container size / (first child size + gap))bufferSizemax(2, ceil(visibleCount * 0.25))uniformSizefactorScaleAll other props (
each,wrap,scrollIndex,onEndReached,onEndReachedThreshold,debugInfo,children, plus inheritedscroll/selected/onSelectedChanged) are unchanged.VirtualGridis untouched.How it works
updateLayout()the container'swidth/heightand the first child's size are read;visibleCount,bufferSize, anditemSizeare cached in a single signal.computeSlicestate machine takes over — all the scroll / wrap / edge logic from before is preserved verbatim.Caller-facing behavior change
width(Row) orheight(Column) on first layout — either explicit, or sized by a flex parent. If the container has no size on the first measurement attempt, the effect re-runs wheneachupdates.Test plan
npm run tsc— cleannpm run lint— 0 errors (warnings are pre-existing)npm test— 120/120 passingVirtualRowandVirtualColumnto confirm one-frame measurement is imperceptible and scroll behavior matches v1wrap,scrollIndex, andscroll: 'edge' | 'always' | 'auto'modes still behave as before🤖 Generated with Claude Code