UNPKG

@opencloud-eu/design-system

Version:

OpenCloud Design System is used to design OpenCloud UI components

30 lines (29 loc) 640 B
import { ref as i, unref as f, watch as v, onBeforeUnmount as w } from "vue"; const d = ({ target: s, mode: o = "show", rootMargin: t = "100px", onVisibleCallback: r }) => { if (!(window && "IntersectionObserver" in window)) return { isVisible: i(!0) }; const e = i(!1), n = new IntersectionObserver( (u) => { const c = u.at(-1).isIntersecting; e.value = c, f(e) && r && r(), o !== "showHide" && e.value && n.unobserve(s.value); }, { rootMargin: t } ); return v(s, () => { n.observe(s.value); }), w(() => n.disconnect()), { isVisible: e }; }; export { d as u };