Back to library
INTERACTION_152

Grid Distortion.

A technical grid bends gently around a moving focus point. An even undistorted grid before the trigger; scaling and offsetting the masked grid region around the focus point once in view, with the focus point drifting or following the pointer.

CATEGORY
Background
COMPLEXITY
Intermediate
TECH
CSS
PLATFORM
Both
PERFORMANCE
Medium
LIVE PLAYGROUND
CSS / CSS
/* Grid Distortion — A technical grid bends gently around a moving focus point. */
.grid-distortion {
  --dur: 10s;
  --ease: ease-in-out;
  --stagger: 60ms;
  will-change: transform, opacity;
}

.grid-distortion > * {
  opacity: 0;
  transform: translateY(14px);
  animation: grid-distortion-in var(--dur) var(--ease) forwards;
  animation-delay: calc(var(--i, 0) * var(--stagger));
}

/* an even undistorted grid -> scaling and offsetting the masked grid region around the focus point */
@keyframes grid-distortion-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .grid-distortion > * {
    opacity: 1;
    transform: none;
    animation: none;
  }
}
React / TSX
import { useEffect, useRef } from "react";

/** Grid Distortion — trigger: in view, with the focus point drifting or following the pointer */
export function GridDistortion({ children }: { children: React.ReactNode }) {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current;
    if (!el) return;
    if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
      el.dataset["state"] = "in";
      return;
    }
    const io = new IntersectionObserver(
      ([entry]) => {
        if (entry?.isIntersecting) {
          el.dataset["state"] = "in";
          io.unobserve(el);
        }
      },
      { threshold: 0.2 },
    );
    io.observe(el);
    return () => io.disconnect();
  }, []);

  return (
    <div ref={ref} className="grid-distortion" data-state="out">
      {children}
    </div>
  );
}

IF YOU LIKE THIS, STEAL THESE TOO.

INTERACTION_155CSS

3D Wireframe

A perspective wireframe plane recedes into the distance.

Background / MediumView
LOVABLECURSORBOLTV0REPLITWINDSURFLOVABLECURSORBOLTV0REPLITWINDSURF
INTERACTION_022CSS

Logo Marquee

Infinite horizontal scroll with edge fades.

Background / LightView
STRUCTURE / 56PX
INTERACTION_023CSS

Tech Grid

Faint technical grid with a radial fade.

Background / LightView
TEXTURE / 3%
INTERACTION_024CSS

Grain Overlay

Film grain that stops black from looking flat.

Background / LightView