fix(virtual-scroll): align scrollToIndex with measured and compressed items - #2410
Merged
Merged
Conversation
… items layoutComplete resolved before the ResizeObserver measured the rendered items, because a frame runs its animation frame callbacks first. So scrollToIndex stopped its correction early. Wait for a task after each frame, and settle only after a frame with no render. Under coordinate compression, the ratio of the sizes left the last items out of reach, and the content moved at DOM scale inside a window, so items landed tens of pixels off and jumped when the window moved. Map the scroll ranges onto each other, and move the content on each scroll while the list is compressed.
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Browser-specific frame timing and extreme-coordinate behavior warrant final human validation.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes virtual-scroll alignment after measurement and under coordinate compression.
Changes:
- Waits for post-frame measurements before settling layout.
- Maps virtual and DOM scroll ranges accurately.
- Adds regression tests and documentation.
| File | Description |
|---|---|
virtualization.ts |
Repositions content and improves layout settling. |
virtualization.spec.ts |
Adds alignment and compression tests. |
engine.ts |
Corrects compressed-coordinate calculations. |
engine.spec.ts |
Tests revised engine mathematics. |
spec.md |
Documents behavior and test scenarios. |
CHANGELOG.md |
Records user-facing fixes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Description
layoutComplete resolved before the ResizeObserver measured the rendered items, because a frame runs its animation frame callbacks first. So scrollToIndex stopped its correction early. Wait for a task after each frame, and settle only after a frame with no render.
Under coordinate compression, the ratio of the sizes left the last items out of reach, and the content moved at DOM scale inside a window, so items landed tens of pixels off and jumped when the window moved. Map the scroll ranges onto each other, and move the content on each scroll while the list is compressed.
Type of Change
Checklist
CHANGELOG.mdentry under[Unreleased]