{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"scroll-card-deal","type":"registry:component","title":"Scroll Card Deal","description":"A pile of cards that fans out symmetrically as its section crosses the viewport.","dependencies":["framer-motion"],"registryDependencies":[],"files":[{"path":"components/viberdy/scroll-card-deal.tsx","content":"\"use client\";\n\nimport { useRef } from \"react\";\nimport { motion, useScroll, useTransform, type MotionValue } from \"framer-motion\";\n\ntype Card = { id: string; title: string };\n\nexport function ScrollCardDeal({\n  cards,\n  spread = 1,\n  rotation = 8,\n  scaleIn = true,\n}: {\n  cards: Card[];\n  spread?: number;\n  rotation?: number;\n  /** Grow the cards as they deal, instead of dealing them at full size. */\n  scaleIn?: boolean;\n}) {\n  const sectionRef = useRef<HTMLDivElement>(null);\n\n  // offset maps \"section top hits viewport bottom\" -> 0 and \"section bottom\n  // hits viewport top\" -> 1, so the deal is driven by the section's own\n  // passage through the viewport rather than by absolute page position.\n  const { scrollYProgress } = useScroll({\n    target: sectionRef,\n    offset: [\"start end\", \"end start\"],\n  });\n\n  return (\n    <div ref={sectionRef} className=\"relative h-[200vh]\">\n      <div className=\"sticky top-1/3 flex justify-center\">\n        <div className=\"relative h-40 w-56\">\n          {cards.map((card, i) => (\n            <DealtCard\n              key={card.id}\n              progress={scrollYProgress}\n              index={i}\n              total={cards.length}\n              spread={spread}\n              rotation={rotation}\n              scaleIn={scaleIn}\n              card={card}\n            />\n          ))}\n        </div>\n      </div>\n    </div>\n  );\n}\n\nfunction DealtCard({\n  progress,\n  index,\n  total,\n  spread,\n  rotation,\n  scaleIn,\n  card,\n}: {\n  progress: MotionValue<number>;\n  index: number;\n  total: number;\n  spread: number;\n  rotation: number;\n  scaleIn: boolean;\n  card: Card;\n}) {\n  // Each card owns an OVERLAPPING slice of the scroll range, so the deal\n  // reads as one continuous motion rather than N discrete steps.\n  const start = (index / total) * 0.8;\n  const end = start + 0.35;\n  const offset = index - (total - 1) / 2;\n\n  // Hooks must run at a component's top level — that is why a dealt card is\n  // its own component rather than a callback inside .map().\n  const x = useTransform(progress, [start, end], [0, offset * 46 * spread]);\n  const y = useTransform(progress, [start, end], [index * 3, 0]);\n  const rotate = useTransform(progress, [start, end], [0, offset * rotation]);\n  const scale = useTransform(progress, [start, end], [scaleIn ? 0.9 : 1, 1]);\n  const opacity = useTransform(progress, [start, start + 0.08], [0.35, 1]);\n\n  return (\n    <motion.div\n      style={{ x, y, rotate, scale, opacity, zIndex: index }}\n      className=\"absolute inset-0 flex flex-col justify-between rounded-lg border border-white/20 bg-[#151922] p-3 shadow-lg\"\n    >\n      <span className=\"font-mono text-[9px] tracking-[0.16em] opacity-60\">{card.id}</span>\n      <span className=\"text-sm font-bold text-white\">{card.title}</span>\n    </motion.div>\n  );\n}\n","type":"registry:component","target":"components/viberdy/scroll-card-deal.tsx"}],"meta":{"tier":"free","tags":["scroll","cards","sticky","framer-motion"],"href":"https://viberdy.dev/library/scroll-card-deal","aiPrompt":"Create a React + Tailwind + Framer Motion component named ScrollCardDeal — a stack of cards that deals outward into a fan as the user scrolls.\n\nBehavior:\n- A tall section (about 200vh) containing a sticky card stack. As the section passes through the viewport, the cards fan out from a single pile: translating horizontally, straightening vertically, rotating outward, and scaling from 0.9 to 1.\n- Card i's horizontal offset and rotation are proportional to (i - (total - 1) / 2), so the fan is symmetric about the centre regardless of how many cards there are.\n\nImplementation requirements:\n- Drive it with useScroll({ target: sectionRef, offset: [\"start end\", \"end start\"] }) so progress is tied to the SECTION's passage through the viewport, not absolute page position. That is what makes the component drop into any page without retuning.\n- Give each card an OVERLAPPING slice of the progress range — start = (i / total) * 0.8, end = start + 0.35 — so the deal reads as one continuous motion instead of N discrete steps.\n- Each card must be its OWN component, not a callback inside .map(). useTransform is a hook and must run at a component's top level; calling it in a map callback breaks the rules of hooks as soon as the list length can change.\n- Animate only transform and opacity so the whole thing stays on the compositor.\n\nProps: cards (array of {id, title}), spread (number multiplier), rotation (degrees per card).\n\nOutput a single self-contained \"use client\" component.","license":"https://viberdy.dev/license"}}