@lanaco/lnc-react-ui
Version:
React component library
40 lines (39 loc) • 988 B
JavaScript
import { jsx as l } from "react/jsx-runtime";
import { useState as f, useMemo as m, useEffect as a, forwardRef as u, useRef as d } from "react";
import { s as p } from "./emotion-styled.browser.esm-DfbrHHed.js";
import { u as I } from "./useUpdateEffect-CuYWz7EA.js";
const w = (s) => {
const [r, t] = f(!1), e = m(
() => new IntersectionObserver(
([n]) => t(n.isIntersecting)
),
[]
);
return a(() => (e.observe(s.current), () => {
e.disconnect();
}), [s, e]), r;
}, h = p.div`
min-height: 1px;
${(s) => s.isHorizontal === !0 ? "min-width: 1px; width: 1px;" : "width: 100%;"}
`, E = u((s, r) => {
const {
onIsVisible: t = () => {
},
onIsNotVisible: e,
isHorizontal: n = !1,
className: c = ""
} = s, i = d(null), o = w(i);
return I(() => {
o ? t() : e == null || e();
}, [o]), /* @__PURE__ */ l(
h,
{
ref: i,
className: `scroller-element ${c}`,
isHorizontal: n
}
);
});
export {
E as I
};