emit "show" event from MkLazy

This commit is contained in:
Hazelnoot 2025-02-27 10:26:36 -05:00
parent 27d43879a2
commit cea77f3e2c

View file

@ -16,10 +16,20 @@ import { nextTick, onMounted, onActivated, onBeforeUnmount, ref, shallowRef } fr
const rootEl = shallowRef<HTMLDivElement>();
const showing = ref(false);
const emit = defineEmits<{
(ev: 'show'): void,
}>();
const observer = new IntersectionObserver(
(entries) => {
if (entries.some((entry) => entry.isIntersecting)) {
showing.value = true;
// Disconnect to avoid observer soft-leaks
observer.disconnect();
// Notify containing element to trigger edge logic
emit('show');
}
},
);