[fix] Improve lazy loading logic in LazyImage component

This commit is contained in:
Johnpaul
2025-08-01 03:30:54 +01:00
parent bfdad0e475
commit e46f682da3

View File

@@ -64,9 +64,7 @@ useIntersectionObserver(
containerRef, containerRef,
(entries) => { (entries) => {
const entry = entries[0] const entry = entries[0]
if (entry?.isIntersecting) { isIntersecting.value = entry?.isIntersecting ?? false
isIntersecting.value = true
}
}, },
{ {
rootMargin, rootMargin,
@@ -96,6 +94,11 @@ watch(
// Fallback to original src // Fallback to original src
cachedSrc.value = src cachedSrc.value = src
} }
} else if (!shouldLoad) {
// Hide image when out of view
isImageLoaded.value = false
cachedSrc.value = undefined
hasError.value = false
} }
}, },
{ immediate: true } { immediate: true }