pleroma-fe/src/components/still-image/still-image.js

32 lines
691 B
JavaScript
Raw Normal View History

2018-01-29 18:47:26 +11:00
const StillImage = {
props: [
'src',
'referrerpolicy',
'mimetype',
'imageLoadError'
2018-01-29 18:47:26 +11:00
],
data () {
return {
stopGifs: this.$store.state.config.stopGifs
}
},
2018-01-29 18:47:26 +11:00
computed: {
animated () {
return this.stopGifs && (this.mimetype === 'image/gif' || this.src.endsWith('.gif'))
2018-01-29 18:47:26 +11:00
}
},
methods: {
onLoad () {
2018-01-29 18:47:26 +11:00
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)
2018-01-29 18:47:26 +11:00
}
}
}
export default StillImage