@opensig/opendesign
Version:
<p align="center"><img src="../docs/public/opendesign-logo-light.png"/></p> <h1 align="center">opendesign</h1> <p align="center">一个 Vue 3 组件库</p> <p align="center"><b>皮肤可定制,使用 TypeScript</b></p>
29 lines (28 loc) • 667 B
JavaScript
import { useIntersectionObserver } from "./use-intersection-observer.mjs";
import { isFunction } from "../_utils/is.mjs";
let io = null;
function useIntersectionObserverDirective({
listener,
removeOnUnmounted
}) {
return {
vIntersectionObserver: {
beforeMount() {
io = useIntersectionObserver();
},
mounted(el) {
if (isFunction(listener)) {
io == null ? void 0 : io.observe(el, listener);
}
},
unmounted(el) {
if (listener && removeOnUnmounted) {
io == null ? void 0 : io.unobserve(el, listener);
}
}
}
};
}
export {
useIntersectionObserverDirective
};