From e46f682da308e750ef18d4d85f55827327399a08 Mon Sep 17 00:00:00 2001 From: Johnpaul Date: Fri, 1 Aug 2025 03:30:54 +0100 Subject: [PATCH] [fix] Improve lazy loading logic in LazyImage component --- src/components/common/LazyImage.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/common/LazyImage.vue b/src/components/common/LazyImage.vue index 1e7fced24..8a3f93978 100644 --- a/src/components/common/LazyImage.vue +++ b/src/components/common/LazyImage.vue @@ -64,9 +64,7 @@ useIntersectionObserver( containerRef, (entries) => { const entry = entries[0] - if (entry?.isIntersecting) { - isIntersecting.value = true - } + isIntersecting.value = entry?.isIntersecting ?? false }, { rootMargin, @@ -96,6 +94,11 @@ watch( // Fallback to original src cachedSrc.value = src } + } else if (!shouldLoad) { + // Hide image when out of view + isImageLoaded.value = false + cachedSrc.value = undefined + hasError.value = false } }, { immediate: true }