feat: data saving mode (#1638)

This commit is contained in:
Tuur Martens 2023-02-15 11:34:23 +01:00 committed by GitHub
parent 52fbb70a08
commit fbe1463f17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 208 additions and 47 deletions

View file

@ -1,10 +1,11 @@
<script setup lang="ts">
import { decode } from 'blurhash'
const { blurhash, src, srcset } = defineProps<{
const { blurhash, src, srcset, shouldLoadImage = true } = defineProps<{
blurhash?: string | null | undefined
src: string
srcset?: string
shouldLoadImage?: boolean
}>()
defineOptions({
@ -19,7 +20,7 @@ const placeholderSrc = $computed(() => {
return getDataUrlFromArr(pixels, 32, 32)
})
onMounted(() => {
function loadImage() {
const img = document.createElement('img')
img.onload = () => {
@ -34,6 +35,16 @@ onMounted(() => {
setTimeout(() => {
isLoaded.value = true
}, 3_000)
}
onMounted(() => {
if (shouldLoadImage)
loadImage()
})
watch(() => shouldLoadImage, () => {
if (shouldLoadImage)
loadImage()
})
</script>