fix: restore double-rAF timing so cold-start divider centering works - #51
Merged
Conversation
v0.15.1 removed the outer requestAnimationFrame that v0.14.0 had, causing realign()'s first step to read target.offsetTop before the browser's first paint. On cold start, contentVisibility:auto post wrappers haven't populated their 'last remembered size' cache yet, so all off-screen posts report 0 intrinsic height and target.offsetTop computes to 0. want=0 matches the current scrollTop=0 so no scroll occurs, leaving the user at the top. Restore the outer rAF so the first realign step fires after the first paint (contentVisibility:auto sizes now correct). Also simplify: replace the pendingCenterRef/centerWhenReady pattern with two separate plain effects, one for flushNonce and one for boundaryNonce — handles are always loaded before SubscribedPage mounts (App.tsx waits for subsLoading), so the divider is always in the DOM when the rAF fires. Remove onDividerRef from PostList. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VxfMbEXhsWRjjXEr5GMcF9
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
requestAnimationFramewrapper that v0.14.0 had. Without it,realign()'s firststepfires one frame too early — before the browser's first paint — whencontentVisibility:autopost wrappers haven't populated their "last remembered size" cache. Every off-screen post reports 0 intrinsic height, sotarget.offsetTopcomputes to 0,want=0matchesscrollTop=0, and no scroll occurs. User is stranded at the top despite a divider existing below.requestAnimationFrame(() => centerScrollOnDivider(el))sorealign()'s step fires after the first paint (correctoffsetTop). Simplify by replacing thependingCenterRef/centerWhenReadypattern with two plain separate effects (one forflushNonce, one forboundaryNonce).onDividerRefremoved fromPostList— it was solving a phantom race that can't happen (App.tsxwaits forsubsLoadingbefore mountingSubscribedPage).Test plan
🤖 Generated with Claude Code
https://claude.ai/code/session_01VxfMbEXhsWRjjXEr5GMcF9