@@ -12,6 +12,7 @@ import { isDef } from '@vueuse/core'
1212import type { VisualElement } from 'framer-motion'
1313import { animate , noop } from 'framer-motion/dom'
1414import { createVisualElement } from '@/state/create-visual-element'
15+ import { prefersReducedMotion } from 'framer-motion/dist/es/utils/reduced-motion/state.mjs'
1516
1617const STATE_TYPES = [ 'initial' , 'animate' , 'whileInView' , 'whileHover' , 'whilePress' , 'whileDrag' , 'whileFocus' , 'exit' ] as const
1718export type StateType = typeof STATE_TYPES [ number ]
@@ -40,8 +41,9 @@ export class AnimationFeature extends Feature {
4041 ...this . state . baseTarget ,
4142 } ,
4243 } ,
43- reducedMotionConfig : this . state . options . motionConfig . reduceMotion ,
44+ reducedMotionConfig : this . state . options . motionConfig . reducedMotion ,
4445 } )
46+
4547 this . state . animateUpdates = this . animateUpdates
4648 if ( this . state . isMounted ( ) )
4749 this . state . startAnimation ( )
@@ -62,6 +64,10 @@ export class AnimationFeature extends Feature {
6264 isFallback,
6365 isExit,
6466 } = { } ) => {
67+ // check if the user has reduced motion
68+ const { reducedMotion } = this . state . options . motionConfig
69+ this . state . visualElement . shouldReduceMotion = reducedMotion === 'always' || ( reducedMotion === 'user' && ! ! prefersReducedMotion . current )
70+
6571 const prevTarget = this . state . target
6672 this . state . target = { ...this . state . baseTarget }
6773 let animationOptions : $Transition = { }
0 commit comments