Update README.md & fix test
This commit is contained in:
@@ -61,10 +61,27 @@ const steps: DemoStepConfig[] = [
|
||||
},
|
||||
];
|
||||
|
||||
const getReducedMotionPreference = () => {
|
||||
if (
|
||||
typeof window === 'undefined' ||
|
||||
typeof window.matchMedia !== 'function'
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
};
|
||||
|
||||
const usePrefersReducedMotion = () => {
|
||||
const [reducedMotion, setReducedMotion] = useState(true);
|
||||
const [reducedMotion, setReducedMotion] = useState(
|
||||
getReducedMotionPreference,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window.matchMedia !== 'function') {
|
||||
return;
|
||||
}
|
||||
|
||||
const query = window.matchMedia('(prefers-reduced-motion: reduce)');
|
||||
const update = () => setReducedMotion(query.matches);
|
||||
update();
|
||||
|
||||
Reference in New Issue
Block a user