Skip to content

A self-hosted media server and file management system

fix: thumbnail does not fade in on first load

aminnausin27e1d41b5d9d
diff --git a/resources/js/components/lazy/LazyImage.vue b/resources/js/components/lazy/LazyImage.vue
index d304e4b5..6a6f89c2 100644
--- a/resources/js/components/lazy/LazyImage.vue
+++ b/resources/js/components/lazy/LazyImage.vue
@@ -9,16 +9,21 @@ import ProIconsPhotoOff from '@/components/icons/ProIconsPhotoOff.vue';
defineOptions({ inheritAttrs: false });
-const props = withDefaults(defineProps<{ src?: string; alt?: string; loading?: ImgHTMLAttributes['loading']; wrapperClass?: HTMLAttributes['class'] }>(), { loading: 'lazy' });
+const props = withDefaults(defineProps<{ src?: string; alt?: string; loading?: ImgHTMLAttributes['loading']; wrapperClass?: HTMLAttributes['class']; animate?: boolean }>(), {
+ loading: 'lazy',
+});
const attrs = useAttrs();
const isLoading = ref(false);
+const isLoaded = ref(false);
const isError = ref(false);
+
watch(
() => props.src,
(src) => {
isError.value = false;
isLoading.value = !!src;
+ isLoaded.value = false;
},
{ immediate: true },
);
@@ -36,10 +41,11 @@ watch(
:loading="loading"
:alt="isError ? '' : alt"
:src="src"
- :class="[{ 'scale-85 opacity-0': isLoading }, 'lazy-image ease-in-out']"
+ :class="[{ 'lazy-image transition-opacity duration-700 ease-in-out': animate }, { loaded: isLoaded }]"
@load="
isLoading = false;
isError = false;
+ isLoaded = true;
"
@error="
isError = true;
@@ -50,7 +56,10 @@ watch(
</template>
<style lang="css" scoped>
.lazy-image {
- will-change: transform, opacity;
- transition-property: opacity, transform;
+ opacity: 0;
+}
+
+.lazy-image.loaded {
+ opacity: 1;
}
</style>
diff --git a/resources/js/components/video/PlayerBackdrop.vue b/resources/js/components/video/PlayerBackdrop.vue
index fa73f548..cb89e155 100644
--- a/resources/js/components/video/PlayerBackdrop.vue
+++ b/resources/js/components/video/PlayerBackdrop.vue
@@ -38,7 +38,7 @@ const generatePosterStyle = (url?: string): HTMLAttributes['style'] => {
<template v-if="isAudio">
<div
id="audio-poster"
- :class="['transition-scale absolute inset-0 scale-105 blur-sm ease-in-out', { 'dark:scale-100': isPlayerSizeConstrained }]"
+ :class="['transition-scale absolute inset-0 -z-1 scale-105 blur-sm ease-in-out', { 'dark:scale-100': isPlayerSizeConstrained }]"
:style="generatePosterStyle(audioPosterUrl)"
></div>
<LazyImage
@@ -51,11 +51,12 @@ const generatePosterStyle = (url?: string): HTMLAttributes['style'] => {
/>
</template>
<div v-else class="contents">
- <div id="thumbnail-blocker" class="absolute inset-0 scale-105 blur-sm" :style="generatePosterStyle(posterUrl)"></div>
+ <div id="thumbnail-blocker" class="absolute inset-0 -z-1 scale-105 blur-sm" :style="generatePosterStyle(posterUrl)"></div>
<LazyImage
:src="handleStorageURL(posterUrl) ?? ''"
alt="thumbnail"
- :class="['mx-auto h-full object-contain transition-all', { 'max-h-[71vh]': isPlayerSizeConstrained }]"
+ :class="['mx-auto h-full object-contain', { 'max-h-[71vh]': isPlayerSizeConstrained }]"
+ :animate="true"
loading="eager"
fetchpriority="high"
/>