Smooth scrolling and WebGL

· Web

A site feels smooth less by doing a lot than by doing little in the right place. On this site I tied scrolling to a single animation loop.

One loop

Smooth scrolling with Lenis feeds every scroll-driven component from the same requestAnimationFrame loop. Components write styles directly instead of going through React state, so scrolling triggers no re-renders.

const loop = (time) => {
  lenis.raf(time);
  subscribers.forEach((fn) => fn(time));
  requestAnimationFrame(loop);
};
The WebGL rock scene that grows on the home page
The WebGL rock scene that grows on the home page

"Growing" images with WebGL

I draw the transition between two images in a fragment shader with a noise mask. As you scroll the mask widens and moss covers the bare stone.

Low-power devices

With "reduce motion" on, animations are turned off and the content is shown directly. Even in a slow browser the site stays readable.