fui-fancyui
Version:
FancyUI Libary
18 lines (17 loc) • 597 B
JavaScript
"use client";
import { useState as r, useEffect as s } from "react";
function I(n, e) {
const [b, u] = r(!1);
return s(() => {
const t = n.current;
if (!t) return;
const f = (l, a) => {
const [c] = l;
u(c.isIntersecting), c.isIntersecting && (e != null && e.freezeOnceVisible) && a.unobserve(t);
}, i = new IntersectionObserver(f, e);
return i.observe(t), () => i.disconnect();
}, [n, e == null ? void 0 : e.threshold, e == null ? void 0 : e.root, e == null ? void 0 : e.rootMargin, e == null ? void 0 : e.freezeOnceVisible]), b;
}
export {
I as default
};