{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "fade-in-view",
  "type": "registry:component",
  "title": "Fade In View",
  "description": "Fades and slides its children in when they scroll into view. Directional, with delay and replay.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "motion",
    "scroll",
    "reveal",
    "fade",
    "intersection"
  ],
  "docs": "https://hyperblur.dev/effects/fade-in-view",
  "files": [
    {
      "path": "registry/hyperblur/fade-in-view.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/fade-in-view.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface FadeInViewProps extends React.HTMLAttributes<HTMLDivElement> {\n  children: React.ReactNode;\n  direction?: \"up\" | \"down\" | \"left\" | \"right\" | \"none\";\n  distance?: number;\n  duration?: number;\n  delay?: number;\n  once?: boolean;\n  threshold?: number;\n}\n\nconst css = `\n.hb-fv { will-change: opacity, transform; }\n.hb-fv[data-inview=\"false\"] {\n  opacity: 0;\n  transform: translate3d(var(--hb-fx), var(--hb-fy), 0);\n  transition: none;\n}\n.hb-fv[data-inview=\"true\"] {\n  opacity: 1;\n  transform: translate3d(0, 0, 0);\n  transition: opacity var(--hb-dur) cubic-bezier(.22, .8, .24, 1) var(--hb-delay), transform var(--hb-dur) cubic-bezier(.22, .8, .24, 1) var(--hb-delay);\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-fv[data-inview] { opacity: 1; transform: none; transition: none; will-change: auto; }\n}\n`;\n\nexport function FadeInView({\n  children,\n  direction = \"up\",\n  distance = 24,\n  duration = 0.7,\n  delay = 0,\n  once = true,\n  threshold = 0.2,\n  className = \"\",\n  style,\n  ...rest\n}: FadeInViewProps) {\n  const ref = React.useRef<HTMLDivElement>(null);\n  const [inView, setInView] = React.useState(false);\n\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    if (typeof IntersectionObserver === \"undefined\") {\n      const id = requestAnimationFrame(() => setInView(true));\n      return () => cancelAnimationFrame(id);\n    }\n    const t = Math.min(1, Math.max(0, threshold));\n    const io = new IntersectionObserver(\n      (entries) => {\n        for (const entry of entries) {\n          if (entry.isIntersecting) {\n            setInView(true);\n            if (once) io.disconnect();\n          } else if (!once) {\n            setInView(false);\n          }\n        }\n      },\n      { threshold: t }\n    );\n    io.observe(el);\n    return () => io.disconnect();\n  }, [once, threshold]);\n\n  const d = Math.max(0, distance);\n  const fx = direction === \"left\" ? d : direction === \"right\" ? -d : 0;\n  const fy = direction === \"up\" ? d : direction === \"down\" ? -d : 0;\n\n  const vars = {\n    \"--hb-fx\": `${fx}px`,\n    \"--hb-fy\": `${fy}px`,\n    \"--hb-dur\": `${Math.max(0, duration)}s`,\n    \"--hb-delay\": `${Math.max(0, delay)}s`,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <div ref={ref} className={`hb-fv ${className}`} style={vars} data-inview={inView} {...rest}>\n      <style href=\"hb-fade-in-view\" precedence=\"default\">{css}</style>\n      {children}\n    </div>\n  );\n}\n"
    }
  ]
}