What
Each chart's requestAnimationFrame paint loop now pauses while its canvas is outside the viewport and resumes — from preserved state, no re-reveal — when it scrolls back in. Pure performance; visually identical, no new prop.
Why
The reveal / star-wink loop runs forever: winkDue alone repaints ~10×/s per chart, indefinitely. On a dashboard with many charts (or a long page where most sit below the fold), every off-screen chart keeps doing full canvas repaints for nothing. Browsers throttle rAF for backgrounded tabs, but not for same-tab off-screen elements — that's the gap.
How
All four canvases share the same loop shape (let raf, a draw that self-schedules, a kickoff + cancelAnimationFrame cleanup). Each now:
- keeps a
visibleflag;drawbails (and clearsraf) while not visible, - starts/stops the loop from an
IntersectionObserveron the canvas, - falls back to always-on when
IntersectionObserveris undefined (SSR / tests).
Continue semantics: the loop's closure state (current, animStart, …) persists across a pause, so scrolling back in resumes without replaying the entrance. Below-the-fold charts simply animate in when first scrolled into view.
Touches cartesian-canvas.tsx, bar-canvas.tsx, pie-canvas.tsx, radar-canvas.tsx — no controller / context / API changes.
Tests
tests/offscreen.test.tsx (mocked IntersectionObserver + rAF spies) asserts the loop doesn't start until the canvas is visible, starts on intersect, and stops when it leaves the viewport. Full suite: 30 passing. Registry regenerated with npm run build:registry.
Summary by Comp AI
No blocking issues found.
Written for commit a2d06f3. New commits will trigger a re-review. Generated by Comp AI.
Activity
6No blocking issues found across the changed files.
Posted by Comp AI Code Reviews.
✅ Comp AI code review complete — no issues found.
Reviewed commit
a2d06f3.Posted by Comp AI Code Reviews.