Skip to content

Commit

Permalink
Disable transition and animation durations if @prefers-reduced-motion.
Browse files Browse the repository at this point in the history
This doesn't include the actual figure SVG animations, only CSS.
  • Loading branch information
elisehein committed Jun 17, 2021
1 parent 0195537 commit 1066454
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/components/AboutSchematics/about-schematics.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ about-schematics {
--appear-animation-duration: .8s;
--appear-animation-easing: cubic-bezier(.16, 1, .3, 1);

@media (prefers-reduced-motion: reduce) {
--appear-animation-duration: 0s;
}

max-width: 70ch;
font-size: var(--ms1);
line-height: var(--triple-baseline);
Expand Down
12 changes: 12 additions & 0 deletions src/components/SchematicsFigure/schematics-figure.css
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@
&--jitter {
animation: jitter var(--schematics-figure-jitter-duration);
animation-direction: reverse;

@media (prefers-reduced-motion: reduce) { animation: none; }
}
}

Expand All @@ -132,6 +134,8 @@

&--hiding &__diagram-container {
animation: jitter var(--jitter-animation-duration);

@media (prefers-reduced-motion: reduce) { animation: none; }
}

&--light-up &__diagram-container {
Expand All @@ -142,6 +146,10 @@
animation:
light-up-diagram var(--schematics-figure-light-up-duration) var(--schematics-figure-light-up-easing),
jitter var(--schematics-figure-jitter-duration) reverse;

@media (prefers-reduced-motion: reduce) {
animation: light-up-diagram var(--schematics-figure-light-up-duration) var(--schematics-figure-light-up-easing);
}
}

&--fuzzy &__diagram-container {
Expand Down Expand Up @@ -190,6 +198,10 @@
animation:
text-shadow-flicker var(--jitter-animation-duration) ease-out,
jitter var(--jitter-animation-duration);

@media (prefers-reduced-motion: reduce) {
animation: text-shadow-flicker var(--jitter-animation-duration) ease-out;
}
}

&--light-up &__figcaption {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ schematics-figure-previews {
--item-max-static-width: 16rem;
--item-size: min(var(--item-max-static-width), var(--item-max-relative-width));

@media (prefers-reduced-motion: reduce) {
--fade-duration: 0s;
--pre-fade-duration: 0s;
}

display: block;
width: 100%;
min-height: var(--item-size); /* Prevents layout shift before previews load */
Expand Down
4 changes: 4 additions & 0 deletions src/css/color-schemes.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@

--color-scheme-transition-duration: .3s;
--color-scheme-transition-easing: cubic-bezier(.25, 1, .5, 1);

@media (prefers-reduced-motion: reduce) {
--color-scheme-transition-duration: 0s;
}
}

[data-color-scheme="light"] {
Expand Down
7 changes: 7 additions & 0 deletions src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
@media (--layout-aside-always-visible) {
--page-padding: var(--triple-baseline);
}

@media (prefers-reduced-motion: reduce) {
--micro-interaction-animation-duration: 0s;
--figure-pre-exit-transition-duration: 0s;
--figure-exit-transition-duration: 0s;
--figure-appear-transition-duration: 0s;
}
}

[data-visible-view*="individual"] {
Expand Down
48 changes: 46 additions & 2 deletions src/main.css

Large diffs are not rendered by default.

0 comments on commit 1066454

Please sign in to comment.