fix: length gauge should respect reduceMotion (#1440)
This commit is contained in:
parent
f6981cff01
commit
fc0f5df6c6
|
@ -1,4 +1,4 @@
|
||||||
<div class="length-gauge {shouldAnimate ? 'should-animate' : ''} {overLimit ? 'over-char-limit' : ''}"
|
<div class={computedClass}
|
||||||
style={computedStyle}
|
style={computedStyle}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
></div>
|
></div>
|
||||||
|
@ -20,6 +20,7 @@
|
||||||
import { store } from '../_store/store'
|
import { store } from '../_store/store'
|
||||||
import { observe } from 'svelte-extras'
|
import { observe } from 'svelte-extras'
|
||||||
import { throttleTimer } from '../_utils/throttleTimer'
|
import { throttleTimer } from '../_utils/throttleTimer'
|
||||||
|
import { classname } from '../_utils/classname'
|
||||||
|
|
||||||
const updateDisplayedLength = process.browser && throttleTimer(requestAnimationFrame)
|
const updateDisplayedLength = process.browser && throttleTimer(requestAnimationFrame)
|
||||||
|
|
||||||
|
@ -50,6 +51,11 @@
|
||||||
const int = Math.round(Math.min(max, length) / max * 100)
|
const int = Math.round(Math.min(max, length) / max * 100)
|
||||||
return (int - (int % 2)) / 100
|
return (int - (int % 2)) / 100
|
||||||
},
|
},
|
||||||
|
computedClass: ({ shouldAnimate, overLimit, $reduceMotion }) => classname(
|
||||||
|
'length-gauge',
|
||||||
|
!$reduceMotion && shouldAnimate && 'should-animate',
|
||||||
|
overLimit && 'over-char-limit'
|
||||||
|
),
|
||||||
computedStyle: ({ style, lengthAsFractionDeferred }) => `transform: scaleX(${lengthAsFractionDeferred}); ${style}`
|
computedStyle: ({ style, lengthAsFractionDeferred }) => `transform: scaleX(${lengthAsFractionDeferred}); ${style}`
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
Loading…
Reference in a new issue