{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"use-scroll","type":"registry:hook","description":"Use scroll hook.","files":[{"path":"hooks/use-scroll.ts","type":"registry:hook","content":"\"use client\";\nimport { useEffect, useState } from \"react\";\n\nexport function useScroll(downThreshold: number, upThreshold?: number) {\n\tconst [scrolled, setScrolled] = useState(false);\n\tconst scrollUpThreshold = upThreshold ?? downThreshold / 2;\n\n\tuseEffect(() => {\n\t\tconst handleScroll = () => {\n\t\t\tconst y = window.scrollY;\n\t\t\t// Hysteresis: different thresholds for up/down to prevent flickering\n\t\t\tsetScrolled((prev) => {\n\t\t\t\tif (prev) {\n\t\t\t\t\t// Currently scrolled - only unscroll when below lower threshold\n\t\t\t\t\treturn y > scrollUpThreshold;\n\t\t\t\t}\n\t\t\t\t// Currently not scrolled - only scroll when above higher threshold\n\t\t\t\treturn y > downThreshold;\n\t\t\t});\n\t\t};\n\n\t\twindow.addEventListener(\"scroll\", handleScroll, { passive: true });\n\t\thandleScroll();\n\t\treturn () => window.removeEventListener(\"scroll\", handleScroll);\n\t}, [downThreshold, scrollUpThreshold]);\n\n\treturn scrolled;\n}\n"}]}