-
Notifications
You must be signed in to change notification settings - Fork 53
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
Provide a disable
option to disable/reduce animation
#124
Comments
Hey @walopee, that is a good point. I'll take a look this weekend. For now you can add a simple workaround, by checking for Live demo: Code: import { useState } from "react";
import AnimateHeight from "react-animate-height";
export default function App() {
const [height, setHeight] = useState("auto");
const reducedMotion = matchMedia("(prefers-reduced-motion)").matches;
return (
<div>
<button onClick={() => setHeight(height === 0 ? "auto" : 0)}>
Toggle
</button>
<AnimateHeight height={height} duration={reducedMotion ? 0 : 500}>
<div
style={{
padding: "50px 20px",
background: "#eee",
border: "1px solid #ddd",
marginTop: 20
}}
>
Hello World
</div>
</AnimateHeight>
</div>
);
} |
Component now respects b7fd78d#diff-af8ea84e12681096191e9bd85c5d016e492d25a9fd8baeedb117a0b6ee46f593 Cheers! |
@Stanko is there any way to enable it? I'd like to force the application to keep the animation for all users even if they set reduce motion, would be great if there's an option as a prop to turn it on/off |
Hey @Bdragon93, Cheers! |
@Stanko unfortunately it doesn't work for me. even from your live demos and codesandbox example Version used: 3.1.1 |
Check this sandbox, it works for me: |
@Stanko I just tried on another Macbook and more browsers - safari/firefox, not work for all. |
additionally, my devices use chip Apple M1, in case it's related |
If a user has "reduce motion" flag on, animation won't work, as that would breaks accessibility. I won't implement "force animation" prop. It works as intended on Chrome, Firefox and Safari. Here is video of Firefox and Chrome with the same sandbox I sent you earlier: disabled-animation.mp4 |
Expected behavior
It would be nice to have the option to conditionally disable the animation for users who have their OS settings set to reduced or no animations
Your Environment
Additional context
This would help fulfill an accessibility best practice by allowing users the option to avoid animations (https://www.w3.org/TR/WCAG21/#animation-from-interactions). I did just realize that this is also achievable by setting the duration to 0 when needed, though 😅
The text was updated successfully, but these errors were encountered: