Back to library
INTERACTION_131

Depth Parallax.

Three layers move at different speeds to build depth. Aligned at their resting offsets before the trigger; translating layers at 0.1, 0.25 and 0.45 of the scroll delta once scroll position relative to the section.

CATEGORY
Scroll
COMPLEXITY
Easy
TECH
CSS
PLATFORM
Both
PERFORMANCE
Light
LIVE PLAYGROUND
CSS / CSS
/* Depth Parallax — Three layers move at different speeds to build depth. */
.depth-parallax {
  --dur: scroll-linked;
  --ease: linear;
  --stagger: 60ms;
  will-change: transform, opacity;
}

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

/* aligned at their resting offsets -> translating layers at 0.1, 0.25 and 0.45 of the scroll delta */
@keyframes depth-parallax-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

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

/** Depth Parallax — trigger: scroll position relative to the section */
export function DepthParallax({ 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="depth-parallax" data-state="out">
      {children}
    </div>
  );
}

IF YOU LIKE THIS, STEAL THESE TOO.

INTERACTION_015CSS + JS

Scroll Reveal

Content fades and rises as it enters the viewport.

Scroll / LightView
INTERACTION_016CSS + JS

Blur Reveal

Content sharpens from blur as it enters view.

Scroll / MediumView
INTERACTION_017CSS + JS

Stagger Reveal

Children enter in sequence with a fixed delay step.

Scroll / LightView
INTERACTION_132CSS

Background Color Transition

Page surfaces shift tone as each section takes over.

Scroll / LightView