chore: rename variable

This commit is contained in:
Michael Brevard 2024-06-20 09:37:55 +03:00 committed by GitHub
parent 0919a82a75
commit f47b0d6c4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,20 +26,20 @@ export const createLazyIOComponent = (componentLoader: Component) => {
const nuxt = useNuxtApp()
const instance = getCurrentInstance()!
const isIntersecting = ref(false)
const hasIntersected = ref(false)
const el: Ref<Element | null> = ref(null)
let unobserve: (() => void) | null = null
// todo can be refactored
if (instance.vnode.el && nuxt.isHydrating) {
isIntersecting.value = elementIsVisibleInViewport(instance.vnode.el as Element)
hasIntersected.value = elementIsVisibleInViewport(instance.vnode.el as Element)
}
if (!isIntersecting.value) {
if (!hasIntersected.value) {
onMounted(() => {
const observer = useIntersectionObserver(attrs.loader as Partial<IntersectionObserverInit> | undefined)
unobserve = observer!.observe(el.value as Element, () => {
isIntersecting.value = true
hasIntersected.value = true
unobserve?.()
unobserve = null
})
@ -51,7 +51,7 @@ export const createLazyIOComponent = (componentLoader: Component) => {
})
return () => {
return h('div', { ref: el }, [
isIntersecting.value ? h(componentLoader, attrs) : (instance.vnode.el && nuxt.isHydrating) ? createStaticVNode(getFragmentHTML(instance.vnode.el ?? null, true)?.join('') || '', 1) : null,
hasIntersected.value ? h(componentLoader, attrs) : (instance.vnode.el && nuxt.isHydrating) ? createStaticVNode(getFragmentHTML(instance.vnode.el ?? null, true)?.join('') || '', 1) : null,
])
}
},