File tree 3 files changed +11
-7
lines changed
src/material/core/animation
3 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ export class AnimationDurations {
53
53
54
54
// @public
55
55
export interface AnimationsConfig {
56
- animationsDisabled: boolean ;
56
+ animationsDisabled? : boolean ;
57
57
}
58
58
59
59
// @public
Original file line number Diff line number Diff line change @@ -7,5 +7,6 @@ ng_project(
7
7
srcs = ["animation.ts" ],
8
8
deps = [
9
9
"//:node_modules/@angular/core" ,
10
+ "//src/cdk/layout" ,
10
11
],
11
12
)
Original file line number Diff line number Diff line change 6
6
* found in the LICENSE file at https://angular.dev/license
7
7
*/
8
8
9
+ import { MediaMatcher } from '@angular/cdk/layout' ;
9
10
import { ANIMATION_MODULE_TYPE , inject , InjectionToken } from '@angular/core' ;
10
11
11
12
/** Object used to configure the animation in Angular Material. */
12
13
export interface AnimationsConfig {
13
14
/** Whether all animations should be disabled. */
14
- animationsDisabled : boolean ;
15
+ animationsDisabled ? : boolean ;
15
16
}
16
17
17
18
/** Injection token used to configure the animations in Angular Material. */
@@ -45,11 +46,13 @@ export class AnimationDurations {
45
46
* @docs -private
46
47
*/
47
48
export function _animationsDisabled ( ) : boolean {
48
- const customToken = inject ( MATERIAL_ANIMATIONS , { optional : true } ) ;
49
-
50
- if ( customToken ) {
51
- return customToken . animationsDisabled ;
49
+ if (
50
+ inject ( MATERIAL_ANIMATIONS , { optional : true } ) ?. animationsDisabled ||
51
+ inject ( ANIMATION_MODULE_TYPE , { optional : true } ) === 'NoopAnimations'
52
+ ) {
53
+ return true ;
52
54
}
53
55
54
- return inject ( ANIMATION_MODULE_TYPE , { optional : true } ) === 'NoopAnimations' ;
56
+ const mediaMatcher = inject ( MediaMatcher ) ;
57
+ return mediaMatcher . matchMedia ( '(prefers-reduced-motion)' ) . matches ;
55
58
}
You can’t perform that action at this time.
0 commit comments