Add prefers-reduced-motion support

This commit is contained in:
David 2023-07-20 16:14:36 -07:00
parent 42ffce97d6
commit e0a6418e91
1 changed files with 6 additions and 2 deletions

View File

@ -12,12 +12,16 @@ const StillImage = {
data () { data () {
return { return {
stopGifs: this.$store.getters.mergedConfig.stopGifs, stopGifs: this.$store.getters.mergedConfig.stopGifs,
isAnimated: false isAnimated: false,
prefersReducedMotion: false
} }
}, },
created () {
this.prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches
},
computed: { computed: {
animated () { animated () {
return this.stopGifs && this.isAnimated return this.stopGifs && this.isAnimated && this.prefersReducedMotion
}, },
style () { style () {
const appendPx = (str) => /\d$/.test(str) ? str + 'px' : str const appendPx = (str) => /\d$/.test(str) ? str + 'px' : str