This commit is contained in:
2026-05-13 17:11:09 +02:00
commit ea63897455
2785 changed files with 359868 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
import { onBeforeUnmount, onMounted, ref } from 'vue';
export const useIntersectionActivation = (options = { rootMargin: '180px 0px' }) => {
const target = ref(null);
const isActive = ref(false);
let observer;
onMounted(() => {
if (typeof IntersectionObserver === 'undefined') {
isActive.value = true;
return;
}
observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (!entry.isIntersecting) {
return;
}
isActive.value = true;
observer?.disconnect();
});
}, options);
if (target.value) {
observer.observe(target.value);
} else {
isActive.value = true;
}
});
onBeforeUnmount(() => {
observer?.disconnect();
});
return {
target,
isActive,
};
};