{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "velocity-marquee-text",
  "title": "Velocity Marquee Text",
  "description": "Oversized marquee rows that answer to your scrolling: they speed up and lean into it, then ease back to a steady drift.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/new-york/velocity-marquee-text/velocity-marquee-text.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface VelocityMarqueeTextProps extends Omit<\n  React.ComponentPropsWithoutRef<\"div\">,\n  \"children\"\n> {\n  /** One entry per row. Rows alternate direction. */\n  rows?: string[];\n  /** Pixels per second at rest. */\n  speed?: number;\n  /** How much scrolling and dragging speed it up. */\n  boost?: number;\n  /** Most it can lean, in degrees. */\n  lean?: number;\n}\n\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(\n    (callback) => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n      query.addEventListener(\"change\", callback);\n      return () => query.removeEventListener(\"change\", callback);\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\nconst ROWS = [\"Faster when you move\", \"Slower when you stop\"];\nconst COPIES = 6;\n\nexport function VelocityMarqueeText({\n  rows = ROWS,\n  speed = 70,\n  boost = 1,\n  lean = 12,\n  className,\n  style,\n  ...props\n}: VelocityMarqueeTextProps) {\n  const reduce = useReducedMotion();\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const trackRefs = React.useRef<(HTMLDivElement | null)[]>([]);\n  const kick = React.useRef(0);\n\n  // Scrolling, wheeling or dragging adds to one velocity that decays, and every row reads from it.\n  React.useEffect(() => {\n    const root = rootRef.current;\n    if (!root || reduce) return;\n    let raf = 0;\n    let prev = 0;\n    let velocity = 0;\n    let lastScroll = window.scrollY;\n    const offsets = rows.map(() => 0);\n    const frame = (now: number) => {\n      const dt = Math.min(0.05, prev ? (now - prev) / 1000 : 1 / 60);\n      prev = now;\n      velocity += (kick.current - velocity) * (1 - Math.exp(-dt * 9));\n      kick.current *= Math.exp(-dt * 3.2);\n      trackRefs.current.slice(0, rows.length).forEach((el, i) => {\n        if (!el) return;\n        const width = el.scrollWidth / COPIES;\n        if (!width) return;\n        const dir = i % 2 ? 1 : -1;\n        offsets[i] += dir * (speed + Math.abs(velocity) * boost) * dt;\n        offsets[i] = ((offsets[i] % width) + width) % width;\n        const skew = Math.max(-lean, Math.min(lean, velocity * 0.012 * dir));\n        el.style.transform = `translate3d(${(-offsets[i]).toFixed(2)}px, 0, 0) skewX(${skew.toFixed(2)}deg)`;\n      });\n      raf = requestAnimationFrame(frame);\n    };\n    const onScroll = () => {\n      kick.current += (window.scrollY - lastScroll) * 6;\n      lastScroll = window.scrollY;\n    };\n    const onWheel = (e: WheelEvent) => {\n      kick.current += e.deltaY * 2.4;\n    };\n    window.addEventListener(\"scroll\", onScroll, { passive: true });\n    root.addEventListener(\"wheel\", onWheel, { passive: true });\n    const io = new IntersectionObserver(([entry]) => {\n      cancelAnimationFrame(raf);\n      prev = 0;\n      if (entry.isIntersecting) raf = requestAnimationFrame(frame);\n    });\n    io.observe(root);\n    return () => {\n      io.disconnect();\n      cancelAnimationFrame(raf);\n      window.removeEventListener(\"scroll\", onScroll);\n      root.removeEventListener(\"wheel\", onWheel);\n    };\n  }, [reduce, rows, speed, boost, lean]);\n\n  return (\n    <div\n      ref={rootRef}\n      className={`w-full overflow-hidden ${className ?? \"\"}`}\n      style={style}\n      role=\"text\"\n      aria-label={rows.join(\". \")}\n      {...props}\n    >\n      {rows.map((row, i) => (\n        <div\n          key={row}\n          ref={(el) => {\n            trackRefs.current[i] = el;\n          }}\n          aria-hidden=\"true\"\n          className=\"flex w-max will-change-transform\"\n        >\n          {Array.from({ length: COPIES }, (_, c) => (\n            <span key={c} className=\"shrink-0 pr-[0.5em] whitespace-nowrap\">\n              {row}\n              <span className=\"pl-[0.5em]\" style={{ opacity: 0.3 }}>\n                /\n              </span>\n            </span>\n          ))}\n        </div>\n      ))}\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}