-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Popover / ToggleGroupControl: Use useReducedMotion()
from @wordpress/compose
#60168
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
cf5c22f
to
e9b6017
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and works as expected 👍 I also checked the source code for the one in Framer, and there was nothing unexpected in there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. The framer-motion
's useReducedMotion
uses the same media query (prefers-reduced-motion)
but it's interesting that they don't bother to listen to the dynamic updates. They just assume that the value is constant for the entire lifetime of the page and read it just once.
One thing that could be inspiring for us is that they use a shared global instance of the media query. Our useReducedMotion
leads to creating 10+ identical media queries, one for each use of the hook. Similarly, useViewportMatch
also leads to multiple identical max-width
/min-width
queries.
I'm not sure if it has any real performance impact, it probably doesn't. MediaQueryList
should be a cheap object.
…ss/compose` (WordPress#60168) * Use useReducedMotion() from @wordpress/compose * CHANGELOG Co-authored-by: tyxla <tyxla@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org>
…ss/compose` (WordPress#60168) * Use useReducedMotion() from @wordpress/compose * CHANGELOG Co-authored-by: tyxla <tyxla@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org>
What?
Use our internal
useReducedMotion()
utility instead of theframer-motion
one.Why?
Our version is more broadly utilized, and it does the same thing, so there's no good reason to use two different versions
How?
We're using the version from
@wordpress/compose
which is already a dependency.Testing Instructions
prefers-reduced-motion
.prefers-reduced-motion
is enabled/disabled.ToggleGroupControl
selected toggle backdrop animation still works well and is properly disabled whenprefers-reduced-motion
is enabled/disabled.Testing Instructions for Keyboard
None
Screenshots or screencast
None