From 3d73849a28ebbe0435029c07f959dfc073d0290b Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 7 May 2023 18:13:32 +0000 Subject: [PATCH] smaller width, height --- .../src/components/MkImgWithBlurhash.vue | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/frontend/src/components/MkImgWithBlurhash.vue b/packages/frontend/src/components/MkImgWithBlurhash.vue index 474ecd361b..caa3895489 100644 --- a/packages/frontend/src/components/MkImgWithBlurhash.vue +++ b/packages/frontend/src/components/MkImgWithBlurhash.vue @@ -1,5 +1,5 @@ @@ -65,16 +65,19 @@ const props = withDefaults(defineProps<{ const viewId = uuid(); const canvas = shallowRef(); +const root = shallowRef(); let loaded = $ref(false); -let canvasWidth = $ref(props.width); -let canvasHeight = $ref(props.height); +let canvasWidth = $ref(64); +let canvasHeight = $ref(64); +let imgWidth = $ref(props.width); +let imgHeight = $ref(props.height); const hide = computed(() => !loaded || props.forceBlurhash); function onLoad() { loaded = true; } -watch([() => props.width, () => props.height], () => { +watch([() => props.width, () => props.height, root], () => { const ratio = props.width / props.height; if (ratio > 1) { canvasWidth = Math.round(64 * ratio); @@ -83,6 +86,10 @@ watch([() => props.width, () => props.height], () => { canvasWidth = 64; canvasHeight = Math.round(64 / ratio); } + + const clientWidth = root.value?.clientWidth ?? 300; + imgWidth = clientWidth; + imgHeight = Math.round(clientWidth / ratio); }, { immediate: true, });