1
0

factor out SkLazy

This commit is contained in:
Hazelnoot
2025-04-13 19:27:44 -04:00
parent 7e9e018b09
commit d647daae0e
3 changed files with 16 additions and 67 deletions
@@ -16,6 +16,8 @@ import { nextTick, onMounted, onActivated, onBeforeUnmount, ref, useTemplateRef
const rootEl = useTemplateRef('rootEl');
const showing = ref(false);
defineExpose({ rootEl, showing });
const emit = defineEmits<{
(ev: 'show'): void,
}>();
@@ -36,13 +38,17 @@ const observer = new IntersectionObserver(
onMounted(() => {
nextTick(() => {
observer.observe(rootEl.value!);
if (rootEl.value) {
observer.observe(rootEl.value);
}
});
});
onActivated(() => {
nextTick(() => {
observer.observe(rootEl.value!);
if (rootEl.value) {
observer.observe(rootEl.value);
}
});
});