Skip to content

fix: restore double-rAF timing so cold-start divider centering works - #51

Merged
lens0021 merged 1 commit into
mainfrom
fix/cold-start-centering-double-raf
Jun 22, 2026
Merged

fix: restore double-rAF timing so cold-start divider centering works#51
lens0021 merged 1 commit into
mainfrom
fix/cold-start-centering-double-raf

Conversation

@lens0021

Copy link
Copy Markdown
Collaborator

Summary

  • Root cause: v0.15.1 removed an outer requestAnimationFrame wrapper that v0.14.0 had. Without it, realign()'s first step fires one frame too early — before the browser's first paint — when contentVisibility:auto post wrappers haven't populated their "last remembered size" cache. Every off-screen post reports 0 intrinsic height, so target.offsetTop computes to 0, want=0 matches scrollTop=0, and no scroll occurs. User is stranded at the top despite a divider existing below.
  • Fix: Restore requestAnimationFrame(() => centerScrollOnDivider(el)) so realign()'s step fires after the first paint (correct offsetTop). Simplify by replacing the pendingCenterRef/centerWhenReady pattern with two plain separate effects (one for flushNonce, one for boundaryNonce). onDividerRef removed from PostList — it was solving a phantom race that can't happen (App.tsx waits for subsLoading before mounting SubscribedPage).

Test plan

  • Cold start from notification tap → divider should be vertically centered on screen
  • "N new" flush → same centering behavior
  • Normal scroll-anchor restore (no divider) → still works (unaffected code path)

🤖 Generated with Claude Code

https://claude.ai/code/session_01VxfMbEXhsWRjjXEr5GMcF9

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
@lens0021
lens0021 merged commit 1165d6a into main Jun 22, 2026
1 check passed
@lens0021
lens0021 deleted the fix/cold-start-centering-double-raf branch June 22, 2026 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant