FIX: remove comment tag; enhance image loading behavior in ProgressiveImage and ImageViewer components

- Added a key to the ProgressiveImage component to ensure proper reactivity when the image source changes.
- Implemented a watcher in the ProgressiveImage component to reset loading state on source changes, improving user experience during image transitions.

These changes enhance the reliability and responsiveness of image handling in the application.
This commit is contained in:
padreug 2025-09-28 13:01:50 +02:00
parent 98934ed61d
commit b69be281f3
2 changed files with 14 additions and 2 deletions

View file

@ -3,6 +3,7 @@
<!-- Primary image display with progressive loading --> <!-- Primary image display with progressive loading -->
<div v-if="currentImageSrc" class="primary-image relative"> <div v-if="currentImageSrc" class="primary-image relative">
<ProgressiveImage <ProgressiveImage
:key="`image-${currentImageIndex}-${currentImageSrc}`"
:src="currentImageSrc" :src="currentImageSrc"
:alt="alt || 'Image'" :alt="alt || 'Image'"
:container-class="containerClass" :container-class="containerClass"

View file

@ -17,7 +17,7 @@
'progressive-image-loaded': isLoaded, 'progressive-image-loaded': isLoaded,
'progressive-image-error': hasError 'progressive-image-error': hasError
} }
]" :loading="loading" @load="handleLoad" @error="handleError" /> --> ]" :loading="loading" @load="handleLoad" @error="handleError" />
<!-- Loading indicator (optional) --> <!-- Loading indicator (optional) -->
<div v-if="showLoadingIndicator && !isLoaded && !hasError" class="progressive-image-loading-indicator"> <div v-if="showLoadingIndicator && !isLoaded && !hasError" class="progressive-image-loading-indicator">
@ -37,7 +37,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, computed, onMounted } from 'vue' import { ref, computed, onMounted, watch } from 'vue'
import { Package } from 'lucide-vue-next' import { Package } from 'lucide-vue-next'
interface Props { interface Props {
@ -189,6 +189,17 @@ onMounted(() => {
} }
}) })
// Watch for src changes and reset loading state
watch(() => props.src, (newSrc, oldSrc) => {
if (newSrc !== oldSrc) {
// Reset loading state when image source changes
isLoaded.value = false
hasError.value = false
isLoading.value = true
emit('loading-start')
}
})
// Expose methods for parent components // Expose methods for parent components
defineExpose({ defineExpose({
reload: () => { reload: () => {