DRAVIS ASI
Web & Mobile • 8 min read • Published 2026-11-14

Engineering 60FPS Procedural Animations and Interactive Visual Studios on the Web

Achieving butter-smooth HTML5 Canvas particle physics, GPU-composited 3D perspective tilts, and zero-jank scroll choreography in React.

By Arush Rawat (Founder & Lead Systems Engineer, RAWMEN STUDIOS)

Why Calling setState on Scroll Kills Frame Rates

Running animations inside React by calling `setState` on every `mousemove` or `scroll` event triggers reconciliation across component trees sixty times per second, causing dropped frames, battery drain, and stuttered scrolling—especially on mobile devices. Smooth 60FPS interfaces decouple animation math from React's render cycle completely.

Instead of storing coordinates in component state, store live pointers and scroll progress in mutable refs (`useRef`) or spring-driven motion values (`useMotionValue`, `useSpring`). The browser's `requestAnimationFrame` callback reads those refs directly onto an HTML5 `<canvas>` or updates GPU-composited `transform` and `opacity` properties without triggering layout reflows.

Respecting Compositor-Only Properties and Cleanup Lifecycles

To keep animations locked at 60FPS+, animate only compositor-friendly properties (`translate3d`, `scale`, `rotateX/Y`, `opacity`) rather than layout properties like `top`, `left`, `width`, or `margin`. Equally important is attaching passive event listeners (`{ passive: true }`) and canceling animation frames cleanly on unmount so background views never leak CPU cycles.

  • Read mouse and scroll inputs from refs inside requestAnimationFrame rather than React state.
  • Use { passive: true } on scroll, wheel, and pointer listeners to keep scrolling immediate.
  • Prefer transform and opacity over width/height/top/left animations.
  • Cap particle counts and skip off-screen drawing when element opacity approaches zero.

Key Takeaways

  • Decouple high-frequency animation frames from React reconciliation cycles.
  • Hardware-accelerated CSS transforms and Canvas loops sustain steady 60FPS motion.
  • Always clean up requestAnimationFrame handles and resize observers on component unmount.