fix(web): use native image decoder ()

Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
Thomas 2023-11-29 15:09:22 +00:00 committed by GitHub
parent e5d083fe79
commit 696900228b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 48 deletions
web/src/lib/components/assets/thumbnail

View file

@ -1,5 +1,5 @@
<script lang="ts">
import { imageLoad } from '$lib/utils/image-load';
import { onMount, tick } from 'svelte';
import { fade } from 'svelte/transition';
import { thumbHashToDataURL } from 'thumbhash';
import { Buffer } from 'buffer';
@ -18,12 +18,20 @@
export let hidden = false;
export let border = false;
export let preload = true;
let complete = false;
export let eyeColor: 'black' | 'white' = 'white';
let complete = false;
let img: HTMLImageElement;
onMount(async () => {
await img.decode();
await tick();
complete = true;
});
</script>
<img
bind:this={img}
loading={preload ? 'eager' : 'lazy'}
style:width={widthStyle}
style:height={heightStyle}
@ -40,8 +48,6 @@
class:rounded-full={circle}
class:opacity-0={!thumbhash && !complete}
draggable="false"
use:imageLoad
on:image-load|once={() => (complete = true)}
/>
{#if hidden}