fix(web): keep starfield centred through zoom-out#219
Conversation
The focused-sun framing shifts the canvas right by sidebarWidth/2 so the target sits in the centre of the visible area (#212). That transform was gated on `zoom !== 1`, so the full shift applied right up to zoom=1 and then vanished on the settle frame — snapping the whole starfield left by sidebarWidth/2 at the end of every zoom-out. Apply the camera transform continuously and ramp the sidebar offset from 0 at zoom=1 to full by minSunFocusZoom (1.8). Every focused state still gets the full offset (#212 centring preserved); zoom-out now settles smoothly with no jump. At zoom=1 / cx=cy=0.5 the transform is the identity, so the default view is pixel-unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Disabled knowledge base sources:
📝 WalkthroughWalkthroughThe animation loop in ChangesStarfield Camera Transform Guard and Sidebar Offset Ramp
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
Zooming out from a focused sun (Return to Stars / clicking the focused sun) ends with the whole starfield snapping sideways by ~
sidebarWidth/2(≈110px on desktop) on the final frame. Zoom-in was already centred (#212); zoom-out was not.Root cause
In
animate.tsthe camera transform that shifts the view right bysidebarWidth/2— so a focused sun lands in the centre of the visible area (right of the sidebar), matching the Zoom Out button atleft: calc(50% + sidebarWidth/2)(#212) — was gated oncameraValues.zoom !== 1:The zoom-out target is
zoom: 1. So the full sidebar shift stays applied right up tozoom = 1, then the transform switches off entirely on the settle frame → the field jumps left bysidebarWidth/2. That discontinuity is the "off-centre" snap.Fix
Apply the camera transform continuously and ramp the sidebar offset from 0 at
zoom = 1to full byminSunFocusZoom(1.8):zoom = 1, cx = cy = 0.5the transform is the identity → the default view is pixel-unchanged.offsetFactor = 1→ full offset → fix(web): center sun zoom + track the focused sun's live orbit #212's focused-sun centring is preserved exactly.The matching
ctx.restore()guard is updated to stay balanced with the (now unconditional)ctx.save().Scope / risk
animate.ts(+24/-6). CSS/render-only; no behavioural change at either rest state (default or focused) — only the transition trajectory is smoothed. Cannot introduce a new snap.Verification
sidebarWidth/2; now continuous).pnpm build:webgreen (deploy gate).Summary by CodeRabbit