File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -9,9 +9,15 @@ export const generateRandomId = () => Math.floor(Math.random() * 1000000);
9
9
export const prefersReducedMotion = ( ( ) => {
10
10
let shouldReduceMotion : boolean | undefined = undefined ;
11
11
return ( ) => {
12
- if ( shouldReduceMotion === undefined && typeof window !== 'undefined' ) {
13
- const mediaQuery = matchMedia ( '(prefers-reduced-motion: reduce)' ) ;
14
- shouldReduceMotion = ! mediaQuery || mediaQuery . matches ;
12
+ if ( shouldReduceMotion === undefined ) {
13
+ if ( typeof window !== 'undefined' && window . matchMedia !== undefined ) {
14
+ const mediaQuery = window . matchMedia (
15
+ '(prefers-reduced-motion: reduce)' ,
16
+ ) ;
17
+ shouldReduceMotion = mediaQuery . matches ;
18
+ } else {
19
+ shouldReduceMotion = false ;
20
+ }
15
21
}
16
22
return shouldReduceMotion ;
17
23
} ;
You can’t perform that action at this time.
0 commit comments