@coreui/vue-pro
Version:
UI Components Library for Vue.js
20 lines (17 loc) • 534 B
JavaScript
import { ref, onMounted, onUnmounted } from 'vue';
const useIsVisible = (el) => {
const isIntersecting = ref(false);
const observer = ref();
onMounted(() => {
observer.value = new IntersectionObserver(([entry]) => {
isIntersecting.value = entry.isIntersecting;
});
el.value && observer.value.observe(el.value);
});
onUnmounted(() => {
observer.value.disconnect();
});
return isIntersecting;
};
export { useIsVisible };
//# sourceMappingURL=useIsVisible.js.map