Skip to content

A self-hosted media server and file management system

fix: display contents on lazyimage is restrictive

aminnausin8ce7d70a4bcf
diff --git a/resources/js/components/lazy/LazyImage.vue b/resources/js/components/lazy/LazyImage.vue
index a5549412..188c2bf9 100644
--- a/resources/js/components/lazy/LazyImage.vue
+++ b/resources/js/components/lazy/LazyImage.vue
@@ -1,12 +1,13 @@
<script setup lang="ts">
-import type { ImgHTMLAttributes } from 'vue';
+import type { HTMLAttributes, ImgHTMLAttributes } from 'vue';
import { SvgSpinners90RingWithBg } from '@/components/cedar-ui/icons';
import { ref, useAttrs, watch } from 'vue';
+import { cn } from '@aminnausin/cedar-ui';
defineOptions({ inheritAttrs: false });
-const props = withDefaults(defineProps<{ src?: string; alt?: string; loading?: ImgHTMLAttributes['loading'] }>(), { loading: 'lazy' });
+const props = withDefaults(defineProps<{ src?: string; alt?: string; loading?: ImgHTMLAttributes['loading']; wrapperClass?: HTMLAttributes['class'] }>(), { loading: 'lazy' });
const attrs = useAttrs();
const isLoading = ref(false);
@@ -21,8 +22,8 @@ watch(
);
</script>
<template>
- <div class="relative contents">
- <div v-if="src && isLoading && !isError" class="absolute inset-0 flex items-center justify-center">
+ <div :class="cn('relative inline-block h-full w-full', wrapperClass)">
+ <div v-show="src && isLoading && !isError" class="absolute inset-0 flex items-center justify-center">
<SvgSpinners90RingWithBg class="size-4" />
</div>
<img
@@ -31,7 +32,7 @@ watch(
:loading="loading"
:alt="alt"
:src="src"
- :class="[{ 'scale-85 opacity-0': isLoading }, 'lazy-image ease-in-out']"
+ :class="cn('lazy-image opacity-100 ease-in-out', { 'scale-85 opacity-0': isLoading })"
@load="
isLoading = false;
isError = false;
@@ -45,6 +46,7 @@ watch(
</template>
<style lang="css" scoped>
.lazy-image {
+ will-change: transform, opacity;
transition-property: opacity, transform;
}
</style>