{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"photo-proof-roll-carousel-that-feeds-over-a-roller-and-curls-onto-the-table","type":"registry:block","title":"Photo Proof Roll Carousel That Feeds over a Roller and Curls onto the Table","description":"Vertical carousel drawn as a roll of photo proofs: paper bends over a chrome roller, hangs facing you and curls onto the table. Free React and HTML code.","dependencies":["framer-motion"],"files":[{"path":"components/we-inc/photo-proof-roll-carousel-that-feeds-over-a-roller-and-curls-onto-the-table.tsx","type":"registry:component","content":"import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\n\n/** The frames printed down the roll, top to bottom in the order they come off the roller. */\nconst frames = [\n  { title: \"Veil, vermilion\", src: \"https://images.pexels.com/photos/18506117/pexels-photo-18506117.jpeg?auto=compress&cs=tinysrgb&w=700\", alt: \"Woman in sunglasses under a sheer orange veil against a vermilion backdrop\", focus: \"50% 30%\" },\n  { title: \"Two neons\", src: \"https://images.pexels.com/photos/9998656/pexels-photo-9998656.jpeg?auto=compress&cs=tinysrgb&w=700\", alt: \"Young woman standing in a haze of blue and red studio light\", focus: \"50% 50%\" },\n  { title: \"Bandaged gloves\", src: \"https://images.pexels.com/photos/39325157/pexels-photo-39325157.jpeg?auto=compress&cs=tinysrgb&w=700\", alt: \"Woman in an orange top and wrapped white gloves posing against an orange backdrop\", focus: \"50% 40%\" },\n  { title: \"Green room\", src: \"https://images.pexels.com/photos/7659347/pexels-photo-7659347.jpeg?auto=compress&cs=tinysrgb&w=700\", alt: \"Woman in a dark suit in profile against a saturated green backdrop\", focus: \"50% 30%\" },\n  { title: \"Rust bodysuit\", src: \"https://images.pexels.com/photos/14999126/pexels-photo-14999126.jpeg?auto=compress&cs=tinysrgb&w=700\", alt: \"Woman with cropped blonde hair in a rust bodysuit against a deep red backdrop\", focus: \"50% 30%\" },\n  { title: \"Yellow wall\", src: \"https://images.pexels.com/photos/35511773/pexels-photo-35511773.jpeg?auto=compress&cs=tinysrgb&w=700\", alt: \"Woman in a grey check blazer leaning one hand on a bright yellow wall\", focus: \"50% 40%\" },\n];\n\nconst N = frames.length;\n// Everything below is in design pixels for a 300 wide roll; the whole scene is scaled to fit.\nconst W = 300; // paper width\nconst PHOTO = 396; // printed photo height\nconst BAND = 58; // white band under each photo that carries the plate caption\nconst PERIOD = PHOTO + BAND;\nconst TOTAL = PERIOD * N;\nconst R1 = 30; // roller radius\nconst RUN = 476; // flat length that hangs facing you\nconst R2 = 86; // radius of the curl where the paper meets the table\nconst TABLE = 330; // length lying on the table\nconst TOP_PAD = 46;\nconst SCENE_W = 760;\nconst SCENE_H = 790;\nconst HOLD_MS = 2800;\n\nconst mod = (a: number, n: number) => ((a % n) + n) % n;\nconst clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));\nconst rad = (d: number) => (d * Math.PI) / 180;\n\ntype Strip = { s: number; h: number; y: number; z: number; a: number; shade: string };\n\n/** Cut the paper path into flat strips: many thin ones round the two curves, one each for the flat runs. */\nfunction buildStrips(): Strip[] {\n  const out: Strip[] = [];\n  const yc = TOP_PAD + R1;\n  const yb = yc + RUN;\n  let s = 0;\n  const topFrom = 104;\n  const nTop = 9;\n  for (let i = 0; i < nTop; i++) {\n    const a0 = topFrom - (topFrom / nTop) * i;\n    const a1 = topFrom - (topFrom / nTop) * (i + 1);\n    const am = (a0 + a1) / 2;\n    const h = R1 * rad(a0 - a1);\n    const dark = 0.62 * Math.pow(Math.sin(rad(clamp(am, 0, 90))), 1.3);\n    const glint = 0.2 * Math.exp(-Math.pow((am - 30) / 16, 2));\n    out.push({\n      s,\n      h,\n      y: yc - R1 * Math.sin(rad(a0)),\n      z: -R1 + R1 * Math.cos(rad(a0)),\n      a: am,\n      shade: `linear-gradient(rgba(255,255,255,${glint.toFixed(3)}),rgba(255,255,255,${glint.toFixed(3)})),linear-gradient(rgba(8,8,10,${dark.toFixed(3)}),rgba(8,8,10,${dark.toFixed(3)}))`,\n    });\n    s += h;\n  }\n  out.push({ s, h: RUN, y: yc, z: 0, a: 0, shade: \"linear-gradient(180deg, rgba(8,8,10,0.30) 0%, rgba(8,8,10,0.06) 7%, rgba(8,8,10,0) 16%, rgba(8,8,10,0) 88%, rgba(255,255,255,0.05) 100%), linear-gradient(102deg, rgba(255,255,255,0) 38%, rgba(255,255,255,0.09) 50%, rgba(255,255,255,0) 63%)\" });\n  s += RUN;\n  const nBot = 16;\n  for (let i = 0; i < nBot; i++) {\n    const a0 = (90 / nBot) * i;\n    const a1 = (90 / nBot) * (i + 1);\n    const am = (a0 + a1) / 2;\n    const h = R2 * rad(a1 - a0);\n    const glint = 0.05 + 0.2 * Math.exp(-Math.pow((am - 52) / 24, 2));\n    out.push({\n      s,\n      h,\n      y: yb + R2 * Math.sin(rad(a0)),\n      z: R2 - R2 * Math.cos(rad(a0)),\n      a: am,\n      shade: `linear-gradient(rgba(255,255,255,${glint.toFixed(3)}),rgba(255,255,255,${glint.toFixed(3)}))`,\n    });\n    s += h;\n  }\n  out.push({ s, h: TABLE, y: yb + R2, z: R2, a: 90, shade: \"linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 30%, rgba(8,8,10,0.2) 100%)\" });\n  return out;\n}\n\nconst S_CENTRE = R1 * rad(104) + RUN / 2; // where along the path a frame sits when it is \"current\"\n\n/** One printed frame: the photograph, crop marks, and the caption band with a colour control strip. */\nfunction Frame({ row, real }: { row: number; real: boolean }) {\n  const i = mod(-row, N);\n  const f = frames[i];\n  return (\n    <div className=\"absolute left-0 w-full\" style={{ top: row * PERIOD, height: PERIOD }}>\n      <div className=\"absolute left-[20px] right-[20px] top-0 overflow-hidden bg-neutral-300\" style={{ height: PHOTO }}>\n        {real ? (\n          <img src={f.src} alt={row < N ? f.alt : \"\"} loading=\"lazy\" draggable={false} className=\"h-full w-full object-cover\" style={{ objectPosition: f.focus }} />\n        ) : (\n          <div className=\"h-full w-full bg-cover\" style={{ backgroundImage: `url(\"${f.src}\")`, backgroundPosition: f.focus }} />\n        )}\n      </div>\n      {/* crop marks in the margins */}\n      <span className=\"absolute left-[6px] top-0 h-px w-[9px] bg-neutral-800/70\" />\n      <span className=\"absolute right-[6px] top-0 h-px w-[9px] bg-neutral-800/70\" />\n      <span className=\"absolute left-[6px] h-px w-[9px] bg-neutral-800/70\" style={{ top: PHOTO - 1 }} />\n      <span className=\"absolute right-[6px] h-px w-[9px] bg-neutral-800/70\" style={{ top: PHOTO - 1 }} />\n      <div className=\"absolute left-[20px] right-[20px] flex items-center justify-between\" style={{ top: PHOTO, height: BAND }}>\n        <div className=\"font-mono text-[8px] uppercase leading-[1.5] tracking-[0.16em] text-neutral-800\">\n          <div className=\"font-semibold\">Plate {String(i + 1).padStart(2, \"0\")}</div>\n          <div className=\"text-neutral-600\">{f.title}</div>\n        </div>\n        <div className=\"flex\">\n          {[\"#19b5e8\", \"#e6177d\", \"#f6d915\", \"#141414\", \"#8a8a8a\", \"#c9c9c9\"].map((c) => (\n            <span key={c} className=\"block h-[9px] w-[9px]\" style={{ background: c }} />\n          ))}\n        </div>\n      </div>\n    </div>\n  );\n}\n\nexport default function PhotoProofRoll() {\n  const reduce = useReducedMotion();\n  const strips = useMemo(buildStrips, []);\n  const wrapRef = useRef<HTMLDivElement>(null);\n  const sceneRef = useRef<HTMLDivElement>(null);\n  const tapeRefs = useRef<(HTMLDivElement | null)[]>([]);\n  const knurlRefs = useRef<(HTMLDivElement | null)[]>([]);\n  const [active, setActive] = useState(0);\n  const sim = useRef({ n: -1.25, vel: 0, target: 0, dragging: false, lastY: 0, lastT: 0, scale: 1, paused: false, nextAuto: 0, active: 0 });\n\n  const step = useCallback((dir: number) => {\n    const s = sim.current;\n    s.target = Math.round(s.target) + dir;\n    s.nextAuto = performance.now() + HOLD_MS * 2;\n  }, []);\n\n  useEffect(() => {\n    const wrap = wrapRef.current;\n    const scene = sceneRef.current;\n    if (!wrap || !scene) return;\n    const s = sim.current;\n    let raf = 0;\n    let visible = true;\n    let last = performance.now();\n    s.nextAuto = last + 2200;\n    if (reduce) s.n = 0;\n\n    const measure = () => {\n      const sc = clamp(wrap.clientWidth / 540, 0.6, 1);\n      s.scale = sc;\n      wrap.style.height = `${Math.round(SCENE_H * sc)}px`;\n      scene.style.transform = `translateX(-50%) scale(${sc.toFixed(4)})`;\n    };\n    measure();\n    const ro = new ResizeObserver(measure);\n    ro.observe(wrap);\n\n    const paint = () => {\n      for (let i = 0; i < strips.length; i++) {\n        const tape = tapeRefs.current[i];\n        if (!tape) continue;\n        const off = mod(strips[i].s - S_CENTRE + PERIOD / 2 - s.n * PERIOD, TOTAL);\n        tape.style.transform = `translate3d(0,${(-off).toFixed(2)}px,0)`;\n      }\n      const turn = mod(s.n * PERIOD, 6);\n      for (const k of knurlRefs.current) if (k) k.style.backgroundPositionY = `${turn.toFixed(2)}px`;\n      const a = mod(Math.round(s.n), N);\n      if (a !== s.active) {\n        s.active = a;\n        setActive(a);\n      }\n    };\n\n    const tick = (now: number) => {\n      const dt = Math.min(0.033, (now - last) / 1000);\n      last = now;\n      if (reduce) {\n        s.n = s.target;\n        s.vel = 0;\n      } else if (!s.dragging) {\n        const acc = 46 * (s.target - s.n) - 9.6 * s.vel;\n        s.vel += acc * dt;\n        s.n += s.vel * dt;\n        if (!s.paused && now > s.nextAuto) {\n          s.target = Math.round(s.target) + 1;\n          s.nextAuto = now + HOLD_MS;\n        }\n      }\n      paint();\n      if (visible) raf = requestAnimationFrame(tick);\n    };\n\n    const io = new IntersectionObserver(([e]) => {\n      const was = visible;\n      visible = e.isIntersecting;\n      if (visible && !was) {\n        last = performance.now();\n        raf = requestAnimationFrame(tick);\n      }\n    });\n    io.observe(wrap);\n    raf = requestAnimationFrame(tick);\n\n    const down = (e: PointerEvent) => {\n      if (e.button !== 0 || !(e.target as HTMLElement).closest(\"[data-paper]\")) return;\n      s.dragging = true;\n      s.lastY = e.clientY;\n      s.lastT = performance.now();\n      s.vel = 0;\n      scene.setPointerCapture(e.pointerId);\n    };\n    const move = (e: PointerEvent) => {\n      if (!s.dragging) return;\n      const now = performance.now();\n      const dn = (e.clientY - s.lastY) / (PERIOD * s.scale);\n      s.n += dn;\n      const dt = Math.max(1, now - s.lastT) / 1000;\n      s.vel = s.vel * 0.6 + (dn / dt) * 0.4;\n      s.lastY = e.clientY;\n      s.lastT = now;\n    };\n    const up = () => {\n      if (!s.dragging) return;\n      s.dragging = false;\n      s.target = Math.round(s.n + clamp(s.vel, -6, 6) * 0.24);\n      s.nextAuto = performance.now() + HOLD_MS * 2;\n    };\n    scene.addEventListener(\"pointerdown\", down);\n    scene.addEventListener(\"pointermove\", move);\n    scene.addEventListener(\"pointerup\", up);\n    scene.addEventListener(\"pointercancel\", up);\n\n    return () => {\n      cancelAnimationFrame(raf);\n      ro.disconnect();\n      io.disconnect();\n      scene.removeEventListener(\"pointerdown\", down);\n      scene.removeEventListener(\"pointermove\", move);\n      scene.removeEventListener(\"pointerup\", up);\n      scene.removeEventListener(\"pointercancel\", up);\n    };\n  }, [reduce, strips]);\n\n  const onKey = (e: React.KeyboardEvent) => {\n    if (e.key === \"ArrowDown\" || e.key === \"ArrowRight\") {\n      e.preventDefault();\n      step(1);\n    } else if (e.key === \"ArrowUp\" || e.key === \"ArrowLeft\") {\n      e.preventDefault();\n      step(-1);\n    }\n  };\n  const pause = (v: boolean) => () => {\n    sim.current.paused = v;\n    if (!v) sim.current.nextAuto = performance.now() + HOLD_MS;\n  };\n\n  const yc = TOP_PAD + R1;\n  const yTable = yc + RUN + R2;\n  const barW = W + 132;\n  const chrome = \"linear-gradient(180deg, #0b0b0c 0%, #2c2d31 14%, #e4e5e8 27%, #9a9ba0 36%, #3a3b40 58%, #17181a 82%, #050506 100%)\";\n  const knurl = \"repeating-linear-gradient(180deg, rgba(0,0,0,0.55) 0px, rgba(0,0,0,0.55) 1.5px, rgba(255,255,255,0.10) 1.5px, rgba(255,255,255,0.10) 3px, rgba(0,0,0,0) 3px, rgba(0,0,0,0) 6px)\";\n  const btn = \"grid h-10 w-10 place-items-center rounded-full border border-white/15 bg-white/5 text-neutral-200 transition hover:bg-white/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white\";\n\n  return (\n    <section className=\"relative overflow-hidden bg-[#0d0d0f]\" onMouseEnter={pause(true)} onMouseLeave={pause(false)} onFocus={pause(true)} onBlur={pause(false)}>\n      {/* a pool of light on the wall behind the roll */}\n      <div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0\" style={{ background: \"radial-gradient(60% 62% at 50% 40%, #3b3c41 0%, #25262a 38%, #131315 72%, #0b0b0d 100%)\" }} />\n      <div\n        ref={wrapRef}\n        role=\"group\"\n        aria-roledescription=\"carousel\"\n        aria-label=\"Roll of photo proofs. Use the up and down arrow keys to feed the paper.\"\n        tabIndex={0}\n        onKeyDown={onKey}\n        className=\"relative mx-auto w-full overflow-hidden outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-white/70\"\n        style={{ height: SCENE_H }}\n      >\n        <div\n          ref={sceneRef}\n          className=\"absolute left-1/2 top-0 select-none\"\n          style={{ width: SCENE_W, height: SCENE_H, transformOrigin: \"50% 0\", transform: \"translateX(-50%)\", perspective: \"1400px\", perspectiveOrigin: \"50% 19%\" }}\n        >\n          <div className=\"absolute left-1/2 top-0\" style={{ transformStyle: \"preserve-3d\", width: 0, height: 0 }}>\n            {/* table top, meeting the wall just behind the roller */}\n            <div\n              aria-hidden=\"true\"\n              className=\"absolute\"\n              style={{\n                left: -1500,\n                top: yTable + 1,\n                width: 3000,\n                height: 1000,\n                transformOrigin: \"50% 0\",\n                transform: \"translateZ(-130px) rotateX(90deg)\",\n                background: \"radial-gradient(22% 44% at 50% 30%, #4c4d53 0%, #2a2b2f 45%, #121214 100%)\",\n                boxShadow: \"inset 0 26px 30px -12px rgba(0,0,0,0.75)\",\n              }}\n            />\n            {/* shadow of the hanging paper on the wall */}\n            <div\n              aria-hidden=\"true\"\n              className=\"absolute bg-black\"\n              style={{ left: -W / 2 + 46, top: yc + 4, width: W, height: RUN + R2, transform: \"translateZ(-128px)\", filter: \"blur(26px)\", opacity: 0.6 }}\n            />\n            {/* shadow under the paper lying on the table */}\n            <div\n              aria-hidden=\"true\"\n              className=\"absolute bg-black\"\n              style={{ left: -W / 2 - 4, top: yTable + 0.5, width: W + 46, height: TABLE + 60, transformOrigin: \"50% 0\", transform: \"translateZ(-10px) rotateX(90deg)\", filter: \"blur(14px)\", opacity: 0.85 }}\n            />\n            {/* the two arms that carry the roller */}\n            {[-1, 1].map((side) => (\n              <div\n                key={side}\n                aria-hidden=\"true\"\n                className=\"absolute\"\n                style={{ left: side * (barW / 2 - 13) - 7, top: -40, width: 14, height: yc + 40 + 6, transform: `translateZ(${-R1 - 3}px)`, background: \"linear-gradient(90deg, #0a0a0b, #4a4b50 40%, #1a1a1c 75%, #060607)\", borderRadius: \"0 0 7px 7px\" }}\n              />\n            ))}\n            {/* the roller */}\n            <div aria-hidden=\"true\" className=\"absolute overflow-hidden rounded-[3px]\" style={{ left: -barW / 2, top: yc - R1, width: barW, height: R1 * 2, transform: `translateZ(${-R1 - 1}px)`, background: chrome }}>\n              {[0, 1].map((e) => (\n                <div\n                  key={e}\n                  ref={(el) => {\n                    knurlRefs.current[e] = el;\n                  }}\n                  className=\"absolute inset-y-0 w-[30px]\"\n                  style={{ [e ? \"right\" : \"left\"]: 0, backgroundImage: `${knurl}, linear-gradient(180deg, #050506, #3c3d42 26%, #77787d 32%, #1d1e20 60%, #050506)` }}\n                />\n              ))}\n            </div>\n            {/* the paper */}\n            {strips.map((st, i) => {\n              const big = st.h > 100;\n              const rows = Math.ceil((TOTAL + st.h) / PERIOD);\n              return (\n                <div\n                  key={i}\n                  data-paper=\"\"\n                  className=\"absolute touch-none overflow-hidden bg-[#f5f3ee]\"\n                  style={{\n                    left: -W / 2,\n                    top: 0,\n                    width: W,\n                    height: st.h + (big ? 0 : 1.8),\n                    transformOrigin: \"50% 0\",\n                    transform: `translate3d(0,${st.y.toFixed(2)}px,${st.z.toFixed(2)}px) rotateX(${st.a.toFixed(2)}deg)`,\n                    backfaceVisibility: \"hidden\",\n                    cursor: \"grab\",\n                  }}\n                >\n                  <div\n                    ref={(el) => {\n                      tapeRefs.current[i] = el;\n                    }}\n                    aria-hidden={i === 9 ? undefined : true}\n                    className=\"absolute left-0 top-0 w-full\"\n                    style={{ height: rows * PERIOD, willChange: big ? \"transform\" : undefined }}\n                  >\n                    {Array.from({ length: rows }, (_, row) => (\n                      <Frame key={row} row={row} real={i === 9} />\n                    ))}\n                  </div>\n                  <div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-0\" style={{ background: st.shade, boxShadow: \"inset 1px 0 0 rgba(255,255,255,0.5), inset -1px 0 0 rgba(0,0,0,0.12)\" }} />\n                </div>\n              );\n            })}\n          </div>\n        </div>\n        {/* the far end of the table falls out of the light */}\n        <div aria-hidden=\"true\" className=\"pointer-events-none absolute inset-x-0 bottom-0 h-16\" style={{ background: \"linear-gradient(180deg, rgba(13,13,15,0), rgba(13,13,15,0.7))\" }} />\n\n        <p aria-live=\"polite\" className=\"absolute bottom-5 left-5 font-mono text-[11px] uppercase leading-relaxed tracking-[0.18em] text-neutral-300 sm:bottom-8 sm:left-8\">\n          <span className=\"tabular-nums text-white\">{String(active + 1).padStart(2, \"0\")}</span>\n          <span className=\"mx-2 text-neutral-500\">/</span>\n          <span className=\"tabular-nums\">{String(N).padStart(2, \"0\")}</span>\n          <span className=\"block text-neutral-400\">{frames[active].title}</span>\n        </p>\n        <div className=\"absolute bottom-4 right-4 flex flex-col gap-2 sm:bottom-7 sm:right-8\">\n          <button type=\"button\" onClick={() => step(-1)} aria-label=\"Wind back to the previous proof\" className={btn}>\n            <svg aria-hidden=\"true\" width=\"18\" height=\"18\" viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n              <path d=\"M4 12l6-6 6 6\" />\n            </svg>\n          </button>\n          <button type=\"button\" onClick={() => step(1)} aria-label=\"Feed the next proof\" className={btn}>\n            <svg aria-hidden=\"true\" width=\"18\" height=\"18\" viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n              <path d=\"M4 8l6 6 6-6\" />\n            </svg>\n          </button>\n        </div>\n      </div>\n    </section>\n  );\n}\n"}]}
