framer / motion

Open source, production-ready animation and gesture library for React
https://framer.com/motion
MIT License
22.41k stars 740 forks source link

[FEATURE] Please allow reducedMotion from <MotionConfig> to be used in animate() #2593

Open claudiocalautti opened 2 months ago

claudiocalautti commented 2 months ago

Is your feature request related to a problem? Please describe.

I'm using animate() to manually animate some text nodes in a React component.

I use "Reduce Motion" in the mac settings at all time to avoid sliding between fullscreen(s).

I've wrapped my app with a global <MotionConfig reducedMotion="never">.

However, this setting is not pulled when using animate() manually.

Describe the solution you'd like

I can see there is a TODO comment pending in the VisualElement.ts source: https://github.com/framer/motion/blob/2b270d0dbbec8b0aabaecae9929d33202ae9f8ca/packages/framer-motion/src/render/VisualElement.ts#L243C8-L244C38

Would it be possible to pass the global reduced motion config? As the comment says "feels like it could be set globally", this seems a compelling case for making such change.

Describe alternatives you've considered

There should be a way to manually handle the reduced motion capabilities of framer at all instances, currently animate() alone doesn't seem to offer such option as it skips completely the transform animations (if the mac reduced motion settings are enabled), in alternative or optionally (for when used outside react) a direct config should also be allowed into animate()'s own options.