factor out SkLazy
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user