A sticky scroll product tour where the camera pans the real app (2027)

Build a sticky scroll feature section in React: features scroll by while the product screen stays pinned, and a camera pans and zooms to the part each feature is about.

6 min read

The real component. Click the picture to open it live and try it before you read how it was built.

Feature sections usually show a cropped screenshot per feature. This tour keeps the whole app on screen and moves a camera over it.

The screen stays, the camera moves

The product screen keeps its real size inside a window. Each feature has a camera point and zoom; when a feature reaches the middle of the screen, the window pans and zooms to it. Narrow screens zoom out by the same share so it still fits.

src/registry/features/scroll-tour/camera-frame.tsx

"use client";

import { useRef, type ReactNode } from "react";
import { motion } from "motion/react";
import { useElementSize } from "@/hooks/use-element-size";
import { cn } from "@/lib/utils";
import type { TourCamera } from "./types";

const PAN = { duration: 0.8, ease: [0.22, 1, 0.36, 1] } as const;
// A camera's zoom is written for a window this wide; narrower windows (phones) zoom out by the same share.
const REFERENCE_WIDTH = 640;

interface CameraFrameProps {
  screen: ReactNode;
  camera: TourCamera;
  className?: string;
}

// A window onto a large product screen. The screen keeps its real size and the camera moves over it: the point it
// looks at is brought to the window's centre at the camera's zoom (as far as the screen's edges allow), and moving
// the camera pans there smoothly.
export function CameraFrame({ screen, camera, className }: CameraFrameProps) {
  const frameRef = useRef<HTMLDivElement>(null);
  const screenRef = useRef<HTMLDivElement>(null);
  const { width, height } = useElementSize(frameRef);
  const screenSize = useElementSize(screenRef);
  const isMeasured = width > 0 && screenSize.width > 0;
  // Centre the camera's point, but never pan past the screen's edges, so the window is always full of product.
  const clamp = (value: number, frame: number, content: number) => Math.min(0, Math.max(frame - content, value));
  const scale = camera.scale * Math.min(1, width / REFERENCE_WIDTH);
  const x = clamp(width / 2 - camera.x * scale, width, screenSize.width * scale);
  const y = clamp(height / 2 - camera.y * scale, height, screenSize.height * scale);

  return (
    <div
      ref={frameRef}
      className={cn("relative overflow-hidden rounded-2xl border border-zinc-200 bg-zinc-100", className)}
    >
      <motion.div
        aria-hidden
        initial={false}
        animate={{ x, y, scale }}
        transition={PAN}
        style={{ transformOrigin: "0 0", opacity: isMeasured ? 1 : 0 }}
        className="absolute top-0 left-0"
      >
        <div ref={screenRef} className="w-max">
          {screen}
        </div>
      </motion.div>
    </div>
  );
}
The camera frame

One step in focus

A step becomes active when it crosses the middle of the screen, and on wide screens the others fade back so the one the camera is showing reads first. On phones the screen sits under each step instead of pinning.

src/registry/features/scroll-tour/tour-step.tsx

"use client";

import { useEffect, useRef } from "react";
import { useInView } from "motion/react";
import { cn } from "@/lib/utils";
import type { TourStep as TourStepData } from "./types";

interface TourStepProps {
  step: TourStepData;
  index: number;
  isActive: boolean;
  onActive: (index: number) => void;
}

// One stop of the tour. It becomes the active stop when it crosses the middle of the screen; on wide screens the
// others fade back so the one the camera is showing reads first.
export function TourStep({ step, index, isActive, onActive }: TourStepProps) {
  const ref = useRef<HTMLDivElement>(null);
  const isCentred = useInView(ref, { margin: "-45% 0px -45% 0px" });

  useEffect(() => {
    if (isCentred) onActive(index);
  }, [isCentred, index, onActive]);

  return (
    <div ref={ref} className="flex max-w-sm flex-col gap-2 lg:py-36">
      <h3
        className={cn(
          "text-xl font-medium transition-colors duration-300",
          isActive ? "text-zinc-950" : "text-zinc-950 lg:text-zinc-400",
        )}
      >
        {step.title}
      </h3>
      <p
        className={cn(
          "text-pretty transition-colors duration-300",
          isActive ? "text-zinc-600" : "text-zinc-600 lg:text-zinc-400",
        )}
      >
        {step.body}
      </p>
    </div>
  );
}
A step of the tour

Bring your own screen

The example is an invoicing app drawn in code. Replace it with your own product's screen and point the cameras at its parts.

More articles