Skip to content

Commit

Permalink
Begin adding support for the prefers-reduced-motion setting, Add a1…
Browse files Browse the repository at this point in the history
…1y notes to the animation docs. (#14021)
  • Loading branch information
kjellr authored and youknowriad committed Mar 20, 2019
1 parent 4abfd11 commit ed42016
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions assets/stylesheets/_animations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
@mixin edit-post__fade-in-animation($speed: 0.2s, $delay: 0s) {
animation: edit-post__fade-in-animation $speed ease-out $delay;
animation-fill-mode: forwards;
@include reduce-motion;
}
10 changes: 10 additions & 0 deletions assets/stylesheets/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,13 @@
// icon standards.
margin-right: 2px;
}

/**
* Allows users to opt-out of animations via OS-level preferences.
*/

@mixin reduce-motion {
@media (prefers-reduced-motion: reduce) {
animation-duration: 1ms !important;
}
}
7 changes: 7 additions & 0 deletions docs/designers-developers/designers/animation.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ In creating consistent animations, we have to establish physical rules for how e

Reuse animations if one already exists for your task.

## Accessibility Considerations

- Animations should be subtle. Be cognizent of users with [vestibular disorders triggered by motion](https://www.ncbi.nlm.nih.gov/pubmed/29017000).
- Don't animate elements that are currently reporting content to adaptive technology (e.g., an `aria-live` region that's receiving updates). This can cause confusion wherein the technology tries to parse a region that's actively changing.
- Avoid animations that aren't directly triggered by user behaviors.
- Whenever possible, ensure that animations respect the OS-level "Reduce Motion" settings. This can be done by utilizing the [`prefers-reduce-motion`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion) media query. Gutenberg includes a `@reduce-motion` mixin for this, to be used alongside rules that include a CSS `animate` property.

## Inventory of Reused Animations

The generic `Animate` component is used to animate different parts of the interface. See [the component documentation](/packages/components/src/animate/README.md) for more details about the available animations.
2 changes: 2 additions & 0 deletions packages/components/src/animate/style.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.components-animate__appear {
animation: components-animate__appear-animation 0.1s cubic-bezier(0, 0, 0.2, 1) 0s;
animation-fill-mode: forwards;
@include reduce-motion;

&.is-from-top,
&.is-from-top.is-from-left {
Expand Down Expand Up @@ -30,6 +31,7 @@
.components-animate__slide-in {
animation: components-animate__slide-in-animation 0.1s cubic-bezier(0, 0, 0.2, 1);
animation-fill-mode: forwards;
@include reduce-motion;

&.is-from-left {
transform: translateX(+100%);
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/modal/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
// Animate the modal frame/contents appearing on the page.
animation: components-modal__appear-animation 0.1s ease-out;
animation-fill-mode: forwards;
@include reduce-motion;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ body.js.is-fullscreen-mode {
.edit-post-header {
transform: translateY(-100%);
animation: edit-post-fullscreen-mode__slide-in-animation 0.1s forwards;
@include reduce-motion;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/edit-post/src/components/layout/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
border-left: $border-width solid $light-gray-500;
transform: translateX(+100%);
animation: edit-post-post-publish-panel__slide-in-animation 0.1s forwards;
@include reduce-motion;

body.is-fullscreen-mode & {
top: 0;
Expand Down

0 comments on commit ed42016

Please sign in to comment.