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

32 lines
691 B
JavaScript
Raw Normal View History

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