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