Repository navigation
NXT-21053: Fix VirtualList native scroll animation stopping at an outdated position - #3468
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/5.6.x.develop #3468 +/- ##
=========================================================
+ Coverage 86.31% 86.33% +0.01%
=========================================================
Files 156 156
Lines 7615 7624 +9
Branches 2013 2012 -1
=========================================================
+ Hits 6573 6582 +9
Misses 831 831
Partials 211 211 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…estarting it Cancelling the ongoing animation on every request made the scroll too slow to keep up with the focus while a 5-way key is held, and it reset `scrolling` to false until the next frame, so `onScrollEnd` could fire `onScrollStop` in the middle of a long-press scroll. Keep a single animation loop alive and update its target (and timeout start) on each request, and scale the step by the number of items left to scroll so the speed keeps up with the focus. A single key press scrolls at the same speed as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous rAF mock kept only the last callback, so the stale concurrent loop from before the fix was never run and the tests passed without the fix. Also fix the CHANGELOG wording. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Checklist
Issue Resolved / Feature Added
With
scrollMode="native", holding a 5-way key (long press) on a horizontal/verticalVirtualListcan leave the list scrolled short of the focused item. The focus reaches the first/last item but the list stops at an intermediate position, so the focused item is clipped or completely out of the viewport.It happens when frames are delayed (e.g. a busy device right after boot), so it is intermittent.
Resolution
VirtualListBasic.animateScroll()started a newrequestAnimationFrameloop on every call without stopping the ongoing one. During key repeat, several loops ran concurrently:node.scrollTo({left/top: <old target>, behavior: 'smooth'})overrides the latest target.Observed on a device (horizontal list, max scroll 745.5): scroll requests were
204 → 384.5 → 565 → 745.5, but stale fallbacks re-issuedscrollTo(204),scrollTo(384.5),scrollTo(565)after the final request, and the list ended at385/565.The fix keeps a single animation loop and retargets it instead of starting another one:
scrollFactor × (number of items left to scroll). A single key press scrolls at the same speed as before. While a key is held, the speed keeps up with the focus, like the overlapping loops did before, without their stale targets.The first revision of this PR cancelled the ongoing animation before starting a new one. Based on review feedback, it was changed because:
cancelScrollAnimation()setscrollingtofalseuntil the next frame, soonScrollEndinui/useScrollwas no longer blocked andonScrollStopfired in the middle of a long-press scroll. With retargeting, the loop is never interrupted andscrollingstaystrue.Additional Considerations
VirtualList-native-specs.js): retargeting keepsscrollingtrue, reaching the latest target, timeout fallback to the latest target, timeout restart on a new request, and faster steps while several items are left. The retarget and speed tests fail with the first revision.VirtualList, 14 items,scrollMode="native", 4K viewport, long press with 50ms key repeat; frames delayed by deferringrequestAnimationFrame):onScrollStopwhile holding (no delay, → / ←)onScrollStopwhile holdingui/ScrolleranimateScrollhas the same pattern (no cancel before restart); not changed here.Links
NXT-21053
Comments
Enact-DCO-1.0-Signed-off-by: Kyuman Lim (kyuman.lim@lge.com)
🤖 Generated with Claude Code