{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "animate-on-scroll",
  "title": "Animate on Scroll",
  "description": "A wrapper that brings content in as it scrolls into view: fade from any side, zoom, blur, flip or a clip-path wipe, one block at once or each child in turn, once or every time, watching the window or any scroll box.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/animate-on-scroll/animate-on-scroll.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, useInView, useReducedMotion, type Variants } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type ScrollEffect = \"fade-up\" | \"fade-down\" | \"fade-left\" | \"fade-right\" | \"zoom-in\" | \"blur-in\" | \"flip-up\" | \"clip-up\";\n\nexport interface AnimateOnScrollProps {\n  children?: React.ReactNode;\n  effect?: ScrollEffect;\n  /** Animate each direct child in turn, this many seconds apart (0 = animate as one block). */\n  stagger?: number;\n  delay?: number;\n  duration?: number;\n  /** Distance (px) for the slide effects. */\n  distance?: number;\n  /** Play only the first time it comes into view. */\n  once?: boolean;\n  /** How much must be visible to start (0–1). */\n  amount?: number;\n  /** A scroll box to watch instead of the window. */\n  root?: React.RefObject<Element | null>;\n  as?: \"div\" | \"section\" | \"ul\" | \"ol\";\n  className?: string;\n}\n\nconst EASE = [0.22, 1, 0.36, 1] as const;\n\nfunction hiddenFor(effect: ScrollEffect, d: number) {\n  switch (effect) {\n    case \"fade-up\":\n      return { opacity: 0, y: d };\n    case \"fade-down\":\n      return { opacity: 0, y: -d };\n    case \"fade-left\":\n      return { opacity: 0, x: d };\n    case \"fade-right\":\n      return { opacity: 0, x: -d };\n    case \"zoom-in\":\n      return { opacity: 0, scale: 0.9 };\n    case \"blur-in\":\n      return { opacity: 0, filter: \"blur(12px)\", y: d / 3 };\n    case \"flip-up\":\n      return { opacity: 0, rotateX: 60, y: d / 2, transformPerspective: 900 };\n    case \"clip-up\":\n      return { clipPath: \"inset(100% 0% 0% 0%)\", y: d / 3 };\n  }\n}\n\nconst SHOWN = { opacity: 1, x: 0, y: 0, scale: 1, rotateX: 0, filter: \"blur(0px)\", clipPath: \"inset(0% 0% 0% 0%)\" };\n\nexport function AnimateOnScroll({ children, effect = \"fade-up\", stagger = 0, delay = 0, duration = 0.7, distance = 32, once = true, amount = 0.25, root, as = \"div\", className }: AnimateOnScrollProps) {\n  const reduce = Boolean(useReducedMotion());\n  const ref = React.useRef<HTMLElement>(null);\n  const inView = useInView(ref, { once, amount, root });\n  const state = reduce || inView ? \"shown\" : \"hidden\";\n\n  const item: Variants = {\n    hidden: reduce ? { opacity: 1 } : hiddenFor(effect, distance),\n    shown: { ...SHOWN, transition: { duration: reduce ? 0 : duration, ease: EASE } },\n  };\n  const Tag = motion[as];\n\n  if (stagger > 0) {\n    const Child = as === \"ul\" || as === \"ol\" ? motion.li : motion.div;\n    return (\n      <Tag ref={ref as never} className={className} initial=\"hidden\" animate={state} variants={{ hidden: {}, shown: { transition: { staggerChildren: reduce ? 0 : stagger, delayChildren: reduce ? 0 : delay } } }}>\n        {React.Children.map(children, (c) => (\n          <Child variants={item} style={{ willChange: \"transform, opacity\" }}>\n            {c}\n          </Child>\n        ))}\n      </Tag>\n    );\n  }\n\n  return (\n    <Tag ref={ref as never} className={cn(className)} initial=\"hidden\" animate={state} variants={{ hidden: item.hidden, shown: { ...SHOWN, transition: { duration: reduce ? 0 : duration, delay: reduce ? 0 : delay, ease: EASE } } }} style={{ willChange: \"transform, opacity\" }}>\n      {children}\n    </Tag>\n  );\n}\n\nexport default AnimateOnScroll;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}