Mirror: React hooks for accessible, common web interactions. UI super powers without the UI.

Respect prefers-reduced-motion

Changed files
+10 -7
src
+10 -7
src/useStyleTransition.ts
···
animation.currentTime = 0.1;
let animating = false;
-
for (const propName in from) {
-
const value = /^--/.test(propName)
-
? element.style.getPropertyValue(propName)
-
: computed[propName];
-
if (value !== from[propName]) {
-
animating = true;
-
break;
+
const media = matchMedia('(prefers-reduced-motion: reduce)');
+
if (!media.matches) {
+
for (const propName in from) {
+
const value = /^--/.test(propName)
+
? element.style.getPropertyValue(propName)
+
: computed[propName];
+
if (value !== from[propName]) {
+
animating = true;
+
break;
+
}
}
}