{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"photo-gallery-columns-moving-at-different-scroll-speeds","type":"registry:block","title":"Photo Gallery Columns Moving at Different Scroll Speeds","description":"","dependencies":[],"files":[{"path":"components/we-inc/photo-gallery-columns-moving-at-different-scroll-speeds.tsx","type":"registry:component","content":"import { useEffect, useRef } from \"react\";\n\n// speed: extra vertical travel per pixel scrolled (negative = runs ahead of the page, positive = lags behind).\nconst COLUMNS = [\n  { speed: 0.12, photos: [{ src: \"https://images.pexels.com/photos/38826747/pexels-photo-38826747.jpeg?auto=compress&cs=tinysrgb&w=700\", alt: \"A narrow dirt path running between tall green trees in a summer forest\" }, { src: \"https://images.pexels.com/photos/34169529/pexels-photo-34169529.jpeg?auto=compress&cs=tinysrgb&w=700\", alt: \"Green and black olives hanging from a silvery olive branch\" }, { src: \"https://images.pexels.com/photos/27667695/pexels-photo-27667695.jpeg?auto=compress&cs=tinysrgb&w=700\", alt: \"A turquoise mountain lake below steep grey peaks and a pine-covered shore\" }] },\n  { speed: -0.22, photos: [{ src: \"https://images.pexels.com/photos/32100798/pexels-photo-32100798.jpeg?auto=compress&cs=tinysrgb&w=700\", alt: \"A still alpine lake reflecting forest and pale rocky mountains\" }, { src: \"https://images.pexels.com/photos/36962671/pexels-photo-36962671.jpeg?auto=compress&cs=tinysrgb&w=700\", alt: \"A wildflower meadow full of pink clover and blue cornflowers\" }, { src: \"https://images.pexels.com/photos/37291897/pexels-photo-37291897.jpeg?auto=compress&cs=tinysrgb&w=700\", alt: \"Old stone cottages with slate roofs under a deep blue sky\" }] },\n  { speed: 0.04, photos: [{ src: \"https://images.pexels.com/photos/36494120/pexels-photo-36494120.jpeg?auto=compress&cs=tinysrgb&w=700\", alt: \"Weathered blue fishing boats moored together in a harbour\" }, { src: \"https://images.pexels.com/photos/14554019/pexels-photo-14554019.jpeg?auto=compress&cs=tinysrgb&w=700\", alt: \"A leafy olive tree with ripe olives lit by sun\" }, { src: \"https://images.pexels.com/photos/33311332/pexels-photo-33311332.jpeg?auto=compress&cs=tinysrgb&w=700\", alt: \"A grassy path leading through a green orchard toward the trees\" }] },\n];\n\nexport default function PhotoGalleryColumnsMovingAtDifferentScrollSpeeds() {\n  const box = useRef<HTMLDivElement>(null);\n  const cols = useRef<(HTMLUListElement | null)[]>([]);\n\n  useEffect(() => {\n    const el = box.current;\n    if (!el) return;\n    const reduce = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    let frame = 0;\n    let on = true;\n    const draw = () => {\n      frame = 0;\n      const s = el.scrollTop; // page scroll: use -el.getBoundingClientRect().top\n      el.classList.toggle(\"w6gal-moved\", s > 8);\n      if (reduce) return;\n      cols.current.forEach((c, i) => {\n        if (c) c.style.transform = `translate3d(0,${(s * COLUMNS[i].speed).toFixed(1)}px,0)`;\n      });\n    };\n    const req = () => {\n      if (on && !frame) frame = requestAnimationFrame(draw);\n    };\n    const io = new IntersectionObserver(([e]) => {\n      on = e.isIntersecting;\n      if (on) req();\n    });\n    io.observe(el);\n    el.addEventListener(\"scroll\", req, { passive: true });\n    return () => {\n      cancelAnimationFrame(frame);\n      io.disconnect();\n      el.removeEventListener(\"scroll\", req);\n    };\n  }, []);\n\n  return (\n    <div ref={box} tabIndex={0} role=\"region\" aria-label=\"Lowfield prints gallery, scrollable preview\" className=\"w6gal relative h-[640px] overflow-y-auto overflow-x-hidden overscroll-contain bg-[#efe9df] text-[#262019] outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[#7a5a3a]\">\n      <style>{`\n        .w6gal-col { will-change: transform; }\n        .w6gal-hint { transition: opacity .5s ease; }\n        .w6gal-moved .w6gal-hint { opacity: 0; }\n        @media (prefers-reduced-motion: reduce) { .w6gal-col { will-change: auto; } }\n      `}</style>\n      <span className=\"w6gal-hint pointer-events-none absolute right-4 top-4 z-10 rounded-full bg-[#262019]/85 px-3 py-1.5 text-xs font-medium text-[#efe9df]\" aria-hidden=\"true\">Scroll inside</span>\n      <div className=\"mx-auto max-w-6xl px-5 pt-12 sm:px-8\">\n        <p className=\"text-xs font-semibold uppercase tracking-[0.24em] text-[#7a5a3a]\">Lowfield Prints</p>\n        <h2 className=\"mt-3 max-w-lg text-3xl font-semibold leading-tight sm:text-4xl\">Quiet places, printed on cotton rag</h2>\n        <div className=\"mt-10 grid grid-cols-2 gap-4 sm:grid-cols-3 sm:gap-6\">\n          {COLUMNS.map((c, i) => (\n            <ul key={i} ref={(n) => { cols.current[i] = n; }} className={`w6gal-col space-y-4 sm:space-y-6 ${i === 1 ? \"mt-16\" : \"\"} ${i === 2 ? \"hidden sm:block\" : \"\"}`}>\n              {c.photos.map((p) => (\n                <li key={p.src} className=\"aspect-[3/4] overflow-hidden rounded-md bg-[#d9cfbf] shadow-[0_16px_32px_-20px_rgba(38,32,25,0.55)]\">\n                  <img src={p.src} alt={p.alt} width={700} height={933} className=\"h-full w-full object-cover\" />\n                </li>\n              ))}\n            </ul>\n          ))}\n        </div>\n      </div>\n      <div className=\"mx-auto mt-24 flex max-w-6xl flex-wrap items-center justify-between gap-4 border-t border-[#262019]/15 px-5 pb-16 pt-8 sm:px-8\">\n        <p className=\"max-w-md text-sm leading-relaxed text-[#5a4f43]\">Every print is made to order in three sizes and signed on the back.</p>\n        <a href=\"#\" className=\"inline-flex h-11 items-center rounded-full bg-[#262019] px-6 text-sm font-semibold text-[#efe9df] hover:bg-[#3d3329] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#262019] focus-visible:ring-offset-2 focus-visible:ring-offset-[#efe9df]\">Browse all prints</a>\n      </div>\n    </div>\n  );\n}\n"}]}
