{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "text-drop-bounce",
  "type": "registry:component",
  "title": "Text Drop Bounce",
  "description": "Letters fall from above one after another, squash on landing and settle with a small rebound. Starts when the text scrolls into view and replays when you hover it. Reduced motion shows the text at rest.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "text",
    "letters",
    "bounce",
    "gravity",
    "scroll",
    "stagger",
    "headline"
  ],
  "docs": "https://hyperblur.dev/effects/text-drop-bounce",
  "files": [
    {
      "path": "registry/hyperblur/text-drop-bounce.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/text-drop-bounce.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface TextDropBounceProps extends React.HTMLAttributes<HTMLSpanElement> {\n  text?: string;\n  stagger?: number;\n  distance?: number;\n  duration?: number;\n  once?: boolean;\n  replayOnHover?: boolean;\n}\n\nconst css = `\n@keyframes hb-db-fall {\n  0% { transform: translateY(var(--hb-db-d)) scale(1, 1.18); opacity: 0; }\n  12% { opacity: 1; }\n  52% { transform: translateY(0) scale(1.16, 0.74); opacity: 1; }\n  72% { transform: translateY(-0.16em) scale(0.97, 1.06); opacity: 1; }\n  88% { transform: translateY(0) scale(1.03, 0.96); opacity: 1; }\n  100% { transform: translateY(0) scale(1, 1); opacity: 1; }\n}\n.hb-db { display: inline-block; }\n.hb-db-w { display: inline-block; white-space: nowrap; }\n.hb-db-c { display: inline-block; opacity: 0; transform-origin: 50% 100%; will-change: transform; }\n.hb-db[data-on=\"true\"] .hb-db-c { animation: hb-db-fall var(--hb-db-t) cubic-bezier(0.3, 0, 0.5, 1) both; animation-delay: calc(var(--i) * var(--hb-db-s)); }\n@media (prefers-reduced-motion: reduce) { .hb-db-c { opacity: 1 !important; animation: none !important; transform: none !important; } }\n`;\n\nexport function TextDropBounce({\n  text = \"Gravity wins\",\n  stagger = 0.05,\n  distance = 1.1,\n  duration = 0.95,\n  once = true,\n  replayOnHover = true,\n  className = \"\",\n  style,\n  onPointerEnter,\n  ...rest\n}: TextDropBounceProps) {\n  const root = React.useRef<HTMLSpanElement>(null);\n  const [on, setOn] = React.useState(false);\n  const busy = React.useRef(false);\n\n  React.useEffect(() => {\n    const el = root.current;\n    if (!el) return;\n    const io = new IntersectionObserver(\n      ([entry]) => {\n        if (entry.isIntersecting) {\n          setOn(true);\n          if (once) io.disconnect();\n        } else if (!once) {\n          setOn(false);\n        }\n      },\n      { threshold: 0.4 },\n    );\n    io.observe(el);\n    return () => io.disconnect();\n  }, [once]);\n\n  const replay = (e: React.PointerEvent<HTMLSpanElement>) => {\n    onPointerEnter?.(e);\n    if (!replayOnHover || busy.current || !on) return;\n    busy.current = true;\n    setOn(false);\n    const total = (stagger * text.length + duration) * 1000;\n    requestAnimationFrame(() =>\n      requestAnimationFrame(() => {\n        setOn(true);\n        window.setTimeout(() => {\n          busy.current = false;\n        }, total);\n      }),\n    );\n  };\n\n  let index = 0;\n  const words = text.split(\" \");\n  const vars = {\n    \"--hb-db-s\": `${stagger}s`,\n    \"--hb-db-t\": `${duration}s`,\n    \"--hb-db-d\": `${-distance}em`,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <span\n      ref={root}\n      className={`hb-db ${className}`}\n      style={vars}\n      data-on={on}\n      role=\"text\"\n      aria-label={text}\n      onPointerEnter={replay}\n      {...rest}\n    >\n      {words.map((word, w) => (\n        <React.Fragment key={w}>\n          {w > 0 ? \" \" : null}\n          <span className=\"hb-db-w\" aria-hidden=\"true\">\n            {Array.from(word).map((ch) => {\n              const i = index++;\n              return (\n                <span key={i} className=\"hb-db-c\" style={{ \"--i\": i } as React.CSSProperties}>\n                  {ch}\n                </span>\n              );\n            })}\n          </span>\n        </React.Fragment>\n      ))}\n      <style href=\"hb-text-drop-bounce\" precedence=\"default\">{css}</style>\n    </span>\n  );\n}\n"
    }
  ]
}