@carton-org/react-neumorphism
Version:
A React component library implementing the neumorphism design style
20 lines (19 loc) • 489 B
JavaScript
import { useRef as u, useEffect as s } from "react";
const i = ({
enable: n = !0,
ref: t,
callback: e
}) => {
const r = u(!1);
s(() => {
r.current && (r.current = !1);
}, [n]), s(() => {
if (!(r.current || !n))
return r.current = !0, ((t == null ? void 0 : t.current) ?? window).addEventListener("scroll", e), () => {
((t == null ? void 0 : t.current) ?? window).removeEventListener("scroll", e);
};
}, [e, n, t]);
};
export {
i as useScroll
};