Use StillImage to render emojis in emoji picker

This commit is contained in:
Tusooa Zhu 2022-01-08 01:35:16 -05:00
commit b77259a9a0
No known key found for this signature in database
GPG key ID: 7B467EDE43A08224
4 changed files with 36 additions and 8 deletions

View file

@ -7,16 +7,23 @@ const StillImage = {
'imageLoadHandler',
'alt',
'height',
'width'
'width',
'dataSrc'
],
data () {
return {
// for lazy loading, see loadLazy()
realSrc: this.src,
stopGifs: this.$store.getters.mergedConfig.stopGifs
}
},
computed: {
animated () {
return this.stopGifs && (this.mimetype === 'image/gif' || this.src.endsWith('.gif'))
if (!this.realSrc) {
return false
}
return this.stopGifs && (this.mimetype === 'image/gif' || this.realSrc.endsWith('.gif'))
},
style () {
const appendPx = (str) => /\d$/.test(str) ? str + 'px' : str
@ -27,7 +34,15 @@ const StillImage = {
}
},
methods: {
loadLazy () {
if (this.dataSrc) {
this.realSrc = this.dataSrc
}
},
onLoad () {
if (!this.realSrc) {
return
}
const image = this.$refs.src
if (!image) return
this.imageLoadHandler && this.imageLoadHandler(image)

View file

@ -11,10 +11,11 @@
<!-- NOTE: key is required to force to re-render img tag when src is changed -->
<img
ref="src"
:key="src"
:key="realSrc"
:alt="alt"
:title="alt"
:src="src"
:data-src="dataSrc"
:src="realSrc"
:referrerpolicy="referrerpolicy"
@load="onLoad"
@error="onError"