yandere_fe/src/components/still-image/still-image.js

35 lines
766 B
JavaScript
Raw Normal View History

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