Skip to content

Commit 940e4ae

Browse files
marcysuttondaneden
authored andcommitted
Add support for prefers-reduced-motion media query (#832)
Feat: add prefers-reduced-motion media query Improve accessibility by respecting the user's preference
1 parent be8582a commit 940e4ae

File tree

6 files changed

+1477
-1461
lines changed

6 files changed

+1477
-1461
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ Next, run `gulp` to compile your custom builds. For example, if you want only so
261261
}
262262
```
263263

264+
## Accessibility
265+
266+
Animate.css supports the [`prefers-reduced-motion` media query](https://webkit.org/blog/7551/responsive-design-for-motion/) so that users with motion sensitivity can opt out of animations. On supported platforms (currently only OSX Safari and iOS Safari), users can select "reduce motion" on their operating system preferences and it will turn off CSS transitions for them without any further work required.
267+
264268
## License
265269

266270
Animate.css is licensed under the MIT license. (http://opensource.org/licenses/MIT)

animate.css

Lines changed: 66 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,63 +8,6 @@
88
* Copyright (c) 2018 Daniel Eden
99
*/
1010

11-
.animated {
12-
-webkit-animation-duration: 1s;
13-
animation-duration: 1s;
14-
-webkit-animation-fill-mode: both;
15-
animation-fill-mode: both;
16-
}
17-
18-
.animated.infinite {
19-
-webkit-animation-iteration-count: infinite;
20-
animation-iteration-count: infinite;
21-
}
22-
23-
.animated.delay-1s {
24-
-webkit-animation-delay: 1s;
25-
animation-delay: 1s;
26-
}
27-
28-
.animated.delay-2s {
29-
-webkit-animation-delay: 2s;
30-
animation-delay: 2s;
31-
}
32-
33-
.animated.delay-3s {
34-
-webkit-animation-delay: 3s;
35-
animation-delay: 3s;
36-
}
37-
38-
.animated.delay-4s {
39-
-webkit-animation-delay: 4s;
40-
animation-delay: 4s;
41-
}
42-
43-
.animated.delay-5s {
44-
-webkit-animation-delay: 5s;
45-
animation-delay: 5s;
46-
}
47-
48-
.animated.fast {
49-
-webkit-animation-duration: 800ms;
50-
animation-duration: 800ms;
51-
}
52-
53-
.animated.faster {
54-
-webkit-animation-duration: 500ms;
55-
animation-duration: 500ms;
56-
}
57-
58-
.animated.slow {
59-
-webkit-animation-duration: 2s;
60-
animation-duration: 2s;
61-
}
62-
63-
.animated.slower {
64-
-webkit-animation-duration: 3s;
65-
animation-duration: 3s;
66-
}
67-
6811
@-webkit-keyframes bounce {
6912
from,
7013
20%,
@@ -3612,3 +3555,69 @@
36123555
-webkit-animation-name: slideOutUp;
36133556
animation-name: slideOutUp;
36143557
}
3558+
3559+
.animated {
3560+
-webkit-animation-duration: 1s;
3561+
animation-duration: 1s;
3562+
-webkit-animation-fill-mode: both;
3563+
animation-fill-mode: both;
3564+
}
3565+
3566+
.animated.infinite {
3567+
-webkit-animation-iteration-count: infinite;
3568+
animation-iteration-count: infinite;
3569+
}
3570+
3571+
.animated.delay-1s {
3572+
-webkit-animation-delay: 1s;
3573+
animation-delay: 1s;
3574+
}
3575+
3576+
.animated.delay-2s {
3577+
-webkit-animation-delay: 2s;
3578+
animation-delay: 2s;
3579+
}
3580+
3581+
.animated.delay-3s {
3582+
-webkit-animation-delay: 3s;
3583+
animation-delay: 3s;
3584+
}
3585+
3586+
.animated.delay-4s {
3587+
-webkit-animation-delay: 4s;
3588+
animation-delay: 4s;
3589+
}
3590+
3591+
.animated.delay-5s {
3592+
-webkit-animation-delay: 5s;
3593+
animation-delay: 5s;
3594+
}
3595+
3596+
.animated.fast {
3597+
-webkit-animation-duration: 800ms;
3598+
animation-duration: 800ms;
3599+
}
3600+
3601+
.animated.faster {
3602+
-webkit-animation-duration: 500ms;
3603+
animation-duration: 500ms;
3604+
}
3605+
3606+
.animated.slow {
3607+
-webkit-animation-duration: 2s;
3608+
animation-duration: 2s;
3609+
}
3610+
3611+
.animated.slower {
3612+
-webkit-animation-duration: 3s;
3613+
animation-duration: 3s;
3614+
}
3615+
3616+
@media (prefers-reduced-motion) {
3617+
.animated {
3618+
-webkit-animation: unset !important;
3619+
animation: unset !important;
3620+
-webkit-transition: none !important;
3621+
transition: none !important;
3622+
}
3623+
}

animate.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function activateAnimations() {
7878
category,
7979
files,
8080
file,
81-
target = ['source/_base.css'],
81+
target = [],
8282
count = 0;
8383

8484
for (category in categories) {
@@ -94,6 +94,8 @@ function activateAnimations() {
9494
}
9595
}
9696
}
97+
// prepend base CSS
98+
target.push('source/_base.css');
9799

98100
if (!count) {
99101
gutil.log('No animations activated.');

0 commit comments

Comments
 (0)