aboutsummaryrefslogtreecommitdiff
path: root/src/components/still-image/still-image.js
diff options
context:
space:
mode:
authorHJ <30-hj@users.noreply.git.pleroma.social>2022-09-22 08:11:25 +0000
committerHJ <30-hj@users.noreply.git.pleroma.social>2022-09-22 08:11:25 +0000
commit03b61f0a9cb09a47d2d9bc89c0a08c62b70c12e2 (patch)
tree4454f5fbc5f2fff4756e410744dc36cba6e35f19 /src/components/still-image/still-image.js
parentaa9cae8c716789b9c0952914ecbb42c1d6762b98 (diff)
parenta7f836a64e334d6c46ed1e12c7bf9b2ff4a09c7e (diff)
Merge branch 'from/develop/tusooa/grouped-emoji-picker' into 'develop'
Group emojis into packs in emoji picker See merge request pleroma/pleroma-fe!1408
Diffstat (limited to 'src/components/still-image/still-image.js')
-rw-r--r--src/components/still-image/still-image.js27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/components/still-image/still-image.js b/src/components/still-image/still-image.js
index d7abbcb5..200ef147 100644
--- a/src/components/still-image/still-image.js
+++ b/src/components/still-image/still-image.js
@@ -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)
@@ -42,6 +57,14 @@ const StillImage = {
onError () {
this.imageLoadError && this.imageLoadError()
}
+ },
+ watch: {
+ src () {
+ this.realSrc = this.src
+ },
+ dataSrc () {
+ this.$el.removeAttribute('data-loaded')
+ }
}
}