{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "use-should-animate",
  "title": "useShouldAnimate",
  "description": "Combines viewport, tab visibility and reduced-motion preference to decide whether a loop should run.",
  "dependencies": [
    "motion"
  ],
  "devDependencies": [],
  "registryDependencies": [
    "https://reactmotionkit.com/r/motion-kit.json",
    "https://reactmotionkit.com/r/use-page-visible.json"
  ],
  "files": [
    {
      "path": "hooks/use-should-animate.ts",
      "content": "\"use client\"\n\nimport { useInView } from \"motion/react\"\nimport { type RefObject } from \"react\"\n\nimport { usePageVisible } from \"@/hooks/use-page-visible\"\nimport { useReducedMotionPolicy } from \"@/lib/motion-kit\"\n\ntype Margin =\n  `${number}px` | `${number}px ${number}px` | `${number}px ${number}px ${number}px ${number}px`\n\ninterface UseShouldAnimateOptions {\n  /** Margin around the viewport, as in IntersectionObserver `rootMargin`. */\n  margin?: Margin\n}\n\n/**\n * Whether a continuous animation (loop, canvas, shader) should be running:\n * the element is on screen, the tab is visible and neither the user nor the\n * `MotionKitProvider` asked for reduced motion.\n */\nexport function useShouldAnimate(\n  ref: RefObject<Element | null>,\n  { margin = \"100px\" }: UseShouldAnimateOptions = {},\n) {\n  const inView = useInView(ref, { margin })\n  const pageVisible = usePageVisible()\n  const reducedMotion = useReducedMotionPolicy()\n\n  return {\n    shouldAnimate: inView && pageVisible && !reducedMotion,\n    inView,\n    pageVisible,\n    reducedMotion,\n  }\n}\n",
      "type": "registry:hook"
    }
  ],
  "meta": {
    "tier": "free",
    "collection": "interface",
    "needsImage": false,
    "addedAt": "2026-10-12",
    "tags": [
      "hook",
      "performance",
      "reduced-motion"
    ],
    "tech": [],
    "presets": [],
    "keyboard": [],
    "heavy": false
  },
  "categories": [
    "internal"
  ],
  "type": "registry:hook"
}