blob: a5559d5d55104496f6aff016fef3be0cf2f17569 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
const StillImage = {
props: [
'src',
'referrerpolicy',
'mimetype',
'imageLoadError'
],
data () {
return {
stopGifs: this.$store.getters.mergedConfig.stopGifs
}
},
computed: {
animated () {
return this.stopGifs && (this.mimetype === 'image/gif' || this.src.endsWith('.gif'))
}
},
methods: {
onLoad () {
const canvas = this.$refs.canvas
if (!canvas) return
const width = this.$refs.src.naturalWidth
const height = this.$refs.src.naturalHeight
canvas.width = width
canvas.height = height
canvas.getContext('2d').drawImage(this.$refs.src, 0, 0, width, height)
},
onError () {
this.imageLoadError && this.imageLoadError()
}
}
}
export default StillImage
|