Back to library
INTERACTION_129

Horizontal Scroll Section.

Vertical scrolling drives a horizontal panel track. The track at translateX(0) before the trigger; translating the track by the remaining track width across the progress range once scroll progress through the pinned section.

CATEGORY
Scroll
COMPLEXITY
Advanced
TECH
CSS + JS
PLATFORM
Both
PERFORMANCE
Medium
LIVE PLAYGROUND
CSS / CSS
/* Horizontal Scroll Section — Vertical scrolling drives a horizontal panel track. */
.horizontal-scroll-section {
  --dur: scroll-linked;
  --ease: linear;
  --stagger: 60ms;
  will-change: transform, opacity;
}

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

/* the track at translateX(0) -> translating the track by the remaining track width across the progress range */
@keyframes horizontal-scroll-section-in {
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

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

/** Horizontal Scroll Section — trigger: scroll progress through the pinned section */
export function HorizontalScrollSection({ 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="horizontal-scroll-section" data-state="out">
      {children}
    </div>
  );
}

IF YOU LIKE THIS, STEAL THESE TOO.

INTERACTION_127CSS

Sticky Storytelling Section

A sticky visual holds while the copy beside it advances.

Scroll / LightView
INTERACTION_128CSS + JS

Pinned Product Showcase

The product mockup is pinned while its features annotate in turn.

Scroll / MediumView
INTERACTION_130CSS + JS

Scroll Controlled Frame Sequence

Scroll scrubs through an image sequence like a film strip.

Scroll / HeavyView
INTERACTION_135CSS

Zoom Through Section

The section scales up and passes the viewer as they scroll.

Scroll / MediumView