emit "show" event from MkLazy
This commit is contained in:
parent
27d43879a2
commit
cea77f3e2c
1 changed files with 10 additions and 0 deletions
|
@ -16,10 +16,20 @@ import { nextTick, onMounted, onActivated, onBeforeUnmount, ref, shallowRef } fr
|
||||||
const rootEl = shallowRef<HTMLDivElement>();
|
const rootEl = shallowRef<HTMLDivElement>();
|
||||||
const showing = ref(false);
|
const showing = ref(false);
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(ev: 'show'): void,
|
||||||
|
}>();
|
||||||
|
|
||||||
const observer = new IntersectionObserver(
|
const observer = new IntersectionObserver(
|
||||||
(entries) => {
|
(entries) => {
|
||||||
if (entries.some((entry) => entry.isIntersecting)) {
|
if (entries.some((entry) => entry.isIntersecting)) {
|
||||||
showing.value = true;
|
showing.value = true;
|
||||||
|
|
||||||
|
// Disconnect to avoid observer soft-leaks
|
||||||
|
observer.disconnect();
|
||||||
|
|
||||||
|
// Notify containing element to trigger edge logic
|
||||||
|
emit('show');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue