mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-24 18:26:17 +03:00
fix: don't include srcset
when showing blur placeholder (#347)
This commit is contained in:
parent
8537f9e0ae
commit
3b6b83ae7a
1 changed files with 7 additions and 2 deletions
|
@ -12,6 +12,10 @@ export default defineComponent({
|
|||
type: String,
|
||||
required: true,
|
||||
},
|
||||
srcset: {
|
||||
type: String,
|
||||
required: false,
|
||||
},
|
||||
},
|
||||
setup(props, { attrs }) {
|
||||
const placeholderSrc = ref<string>()
|
||||
|
@ -19,11 +23,12 @@ export default defineComponent({
|
|||
|
||||
onMounted(() => {
|
||||
const img = document.createElement('img')
|
||||
isLoaded.value = img.complete
|
||||
img.onload = () => {
|
||||
isLoaded.value = true
|
||||
}
|
||||
img.src = props.src
|
||||
if (props.srcset)
|
||||
img.srcset = props.srcset
|
||||
setTimeout(() => {
|
||||
isLoaded.value = true
|
||||
}, 3_000)
|
||||
|
@ -35,7 +40,7 @@ export default defineComponent({
|
|||
})
|
||||
|
||||
return () => isLoaded.value || !placeholderSrc.value
|
||||
? h('img', { ...attrs, src: props.src })
|
||||
? h('img', { ...attrs, src: props.src, srcset: props.srcset })
|
||||
: h('img', { ...attrs, src: placeholderSrc.value })
|
||||
},
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue