Skip to content

Commit 8f3cad5

Browse files
committed
feat: aggressive reduced-motion handling
Disables animations and transitions for users who prefer reduced motion: - animation-duration: 0.01ms - animation-iteration-count: 1 - transition-duration: 0.01ms - scroll-behavior: auto Uses 0.01ms instead of 0ms so animationend/transitionend events still fire and JS doesn't break. Aligned with Andy Bell's approach.
1 parent 0002228 commit 8f3cad5

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

docs/css-reset-comparison.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ This table summarizes all relevant CSS reset recommendations from various source
7070
| `:focus-visible` styling || [Keith Grant][4] | [MDN: :focus-visible](https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible) |
7171
| **Reduced Motion** ||||
7272
| `@media (prefers-reduced-motion: reduce) { scroll-behavior: auto }` || [Jake Lazaroff][5], [Andy Bell][2] | [MDN: prefers-reduced-motion](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion) |
73-
| `@media (prefers-reduced-motion: reduce) { animation-duration: 0.01ms }` | | [Andy Bell][2], [Elly Loel][13] | |
74-
| `@media (prefers-reduced-motion: reduce) { transition-duration: 0.01ms }` | | [Andy Bell][2], [Elly Loel][13] | |
73+
| `@media (prefers-reduced-motion: reduce) { animation-duration: 0.01ms }` | | [Andy Bell][2], [Elly Loel][13] | |
74+
| `@media (prefers-reduced-motion: reduce) { transition-duration: 0.01ms }` | | [Andy Bell][2], [Elly Loel][13] | |
7575
| `@media (prefers-reduced-motion: no-preference) { scroll-behavior: smooth }` || [Andy Bell][2], [Jake Lazaroff][5] | [MDN: scroll-behavior](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior) |
7676
| **Color Scheme** ||||
7777
| `html { color-scheme: light dark }` || [Pawel Grzybek][8], [Keith Grant][4], [Modern Normalize][16] | [MDN: color-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme) · [CSS Color Adjustment Spec](https://drafts.csswg.org/css-color-adjust/#color-scheme-prop) |

src/fixes.css

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,29 +97,32 @@
9797
}
9898

9999
/**
100-
* UFX-020, UFX-021: Respect user preference for reduced motion.
100+
* UFX-020: Respect user preference for reduced motion.
101101
*
102-
* Affected browsers: All browsers that support prefers-reduced-motion
103-
* Description: Users with vestibular motion disorders or motion sensitivity
104-
* can indicate they prefer reduced motion. This ensures smooth scrolling
105-
* is disabled for these users.
102+
* Users with vestibular motion disorders or motion sensitivity can indicate
103+
* they prefer reduced motion. This aggressively disables animations and
104+
* transitions for these users.
105+
*
106+
* Why 0.01ms instead of 0ms?
107+
* Ensures `animationend` and `transitionend` events still fire, so JS
108+
* that depends on these events doesn't break.
106109
*
107110
* References:
108111
* - https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion
109112
* - https://www.smashingmagazine.com/2021/10/respecting-users-motion-preferences/
110113
* - https://web.dev/prefers-reduced-motion/
111114
*
112115
* Aligned with:
113-
* - Josh Comeau – @media (prefers-reduced-motion: reduce) handling
114-
* - Andy Bell (Piccalilli) – more aggressive (animation/transition-duration: 0.01ms)
115-
* - Jake Lazaroff – scroll-behavior: auto
116-
*
117-
* UFX-022: Additional reductions (animation-duration, transition-duration)
118-
* are intentionally omitted in v1 to avoid breaking intentional animations.
119-
* Implementers should handle these in their own stylesheets as needed.
116+
* - Andy Bell (Piccalilli) – animation/transition-duration: 0.01ms
117+
* - Josh Comeau – scroll-behavior handling
120118
*/
121119
@media (prefers-reduced-motion: reduce) {
122-
* {
120+
*,
121+
*::before,
122+
*::after {
123+
animation-duration: 0.01ms !important;
124+
animation-iteration-count: 1 !important;
125+
transition-duration: 0.01ms !important;
123126
scroll-behavior: auto !important;
124127
}
125128
}

0 commit comments

Comments
 (0)