Skip to content

Commit 4208e51

Browse files
committed
Fix (reduced-motion): update mixin to utilize class-based approach for reduced motion handling
1 parent 61ea8fe commit 4208e51

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎src/scss/02-tools/_m-reduced-motion.scss‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
11
/**
22
* Reduced-motion for animations
33
*
4+
* Driven by `html.js-animation` / `html.no-js-animation` (toggled from
5+
* prefers-reduced-motion in header.php, and by the a11y access config plugin).
6+
*
47
* @author Paolo Tesei
58
*
69
* @param $reduce
710
*
811
* Examples :
912
*
1013
* @include reduced-motion { ... }
11-
* return @media screen and (prefers-reduced-motion : reduce) { ... }
14+
* → html.no-js-animation & { ... }
1215
*
1316
* you can add heavy animation using :
1417
*
1518
* @include reduced-motion (false) { ... }
16-
* return @media screen and (prefers-reduced-motion : no-preference) { ... }
19+
* → html.js-animation & { ... }
1720
*
1821
*/
1922

2023
@mixin reduced-motion($reduce: true) {
21-
@if ($reduce == true) {
22-
@media screen and (prefers-reduced-motion: reduce) {
24+
$class: if($reduce, "no-js-animation", "js-animation");
25+
26+
@if not & {
27+
html.#{$class} {
2328
@content;
2429
}
2530
} @else {
26-
@media screen and (prefers-reduced-motion: no-preference) {
31+
html.#{$class} & {
2732
@content;
2833
}
2934
}

0 commit comments

Comments
 (0)