I'm working on adding support for the prefers-reduced-motion on a very animation-heavy site. Since the feature is opt-in and not well supported right now, I need to have my animations outside a media query and then additional CSS rules to disable the animation inside @media screen and (prefers-reduced-motion: reduce) {}
There are two animations, vertical-animate
and horizontal-animate
. Both go from 0% straight to 100% changing opacity from 0 to 1 and top/left from 100px to 0px.
Right now, I have the following in an attempt to reset both the keyframes and animation property:
@media screen and (prefers-reduced-motion: reduce) {
@-webkit-keyframes vertical-animate {}
@keyframes vertical-animate {}
@-webkit-keyframes horizontal-animate {}
@keyframes horizontal-animate {}
* {
-webkit-animation: none !important;
-moz-animation: none !important;
-o-animation: none !important;
animation: none !important;
}
}
This successfully prevents the animation but it also leaves the animated elements invisible! Using dev tools, I can see they're essentially stuck at opacity: 0
and [top/left]: 100px
.
(FWIW, I'm testing without the media query to see the result.)
How can I write additional CSS (as little as possible, please!) that disables an animation so that design appears as it would at the end of the existing completed keyframe animation?