File tree Expand file tree Collapse file tree 3 files changed +11
-7
lines changed
src/material/core/animation Expand file tree Collapse file tree 3 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ export class AnimationDurations {
5353
5454// @public
5555export interface AnimationsConfig {
56- animationsDisabled: boolean ;
56+ animationsDisabled? : boolean ;
5757}
5858
5959// @public
Original file line number Diff line number Diff line change @@ -7,5 +7,6 @@ ng_project(
77 srcs = ["animation.ts" ],
88 deps = [
99 "//:node_modules/@angular/core" ,
10+ "//src/cdk/layout" ,
1011 ],
1112)
Original file line number Diff line number Diff line change 66 * found in the LICENSE file at https://angular.dev/license
77 */
88
9+ import { MediaMatcher } from '@angular/cdk/layout' ;
910import { ANIMATION_MODULE_TYPE , inject , InjectionToken } from '@angular/core' ;
1011
1112/** Object used to configure the animation in Angular Material. */
1213export interface AnimationsConfig {
1314 /** Whether all animations should be disabled. */
14- animationsDisabled : boolean ;
15+ animationsDisabled ? : boolean ;
1516}
1617
1718/** Injection token used to configure the animations in Angular Material. */
@@ -45,11 +46,13 @@ export class AnimationDurations {
4546 * @docs -private
4647 */
4748export 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 ;
5254 }
5355
54- return inject ( ANIMATION_MODULE_TYPE , { optional : true } ) === 'NoopAnimations' ;
56+ const mediaMatcher = inject ( MediaMatcher ) ;
57+ return mediaMatcher . matchMedia ( '(prefers-reduced-motion)' ) . matches ;
5558}
You can’t perform that action at this time.
0 commit comments