-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(motion): add extended support for reduced motion #33353
feat(motion): add extended support for reduced motion #33353
Conversation
📊 Bundle size reportUnchanged fixtures
|
Pull request demo site: URL |
packages/react-components/react-motion/library/src/contexts/MotionBehaviourContext.ts
Outdated
Show resolved
Hide resolved
2f16fd0
to
07ad3b3
Compare
07ad3b3
to
7649e34
Compare
The feature motivation is solid; the feature design needs to be fleshed out a bit more like an RFC (if it's not going to be an actual RFC). For example:
|
FYI, it's was mentioned in the original RFC as a proposal: https://github.com/microsoft/fluentui/blob/master/docs/react-v9/contributing/rfcs/react-components/convergence/motion-definition-n-apis.md#advanced-reduced-motion-support
I updated the PR description to list other two options, is there anything that comes to your mind? Did I miss something?
As the atom definition changes, it will work transparently. I added an example to the PR description. |
packages/react-components/react-motion/library/src/hooks/useAnimateAtoms.ts
Show resolved
Hide resolved
...on/stories/src/CreateMotionComponent/CreateMotionComponentImperativeRefPlayState.stories.tsx
Show resolved
Hide resolved
@layershifter I think you've covered it well.
Excellent additions, thanks. |
7649e34
to
7128361
Compare
packages/react-components/react-motion/library/src/hooks/useAnimateAtoms.ts
Outdated
Show resolved
Hide resolved
packages/react-components/react-motion/library/src/hooks/useAnimateAtoms.ts
Show resolved
Hide resolved
7128361
to
4b6d027
Compare
e86b2df
to
1d7e3a8
Compare
1d7e3a8
to
72b8029
Compare
Previous Behavior
No way to customize motions' behavior when reduced motion is enabled.
New Behavior
reducedMotion
option toAtomMotion
type.By default, when reduced motion is enabled the duration of the animation is set to
1ms
(current behavior).reducedMotion
allows to customize a reduced motion version of the animation:This will also works with arrays of atoms as
reducedMotion
definitions are collocated to its atoms:Rejected options
Second argument to
createMotionComponent()
&createPresenceComponent()
We have already an array syntax for multiple atoms (see createPresenceComponent() and arrays):
The proposal is two have a second argument:
However, it will be hard to distinguish between atoms and reduced motion declarations - you have to know the order of arguments in the functions to understand it.
This implementation also brings a challenge of collocation: reduced options should be optional, however we will need to maintain the order to make it work. The example below shows the requirement:
Consumers will be forced to pass
null
(or something else?) in this case:Nest atoms
That's very similar to previous option, but instead we will have syntax similar to fallback values in Griffel.
In this case we collocate reduced options with the atom they are related to, so we don't need to maintain the order like in the previous option 👍
However, this option has the same issue with being implicit and hard to understand: which array stands for atoms and which for reduced options?
Related issues
Fixes #33358.