Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion goldens/material/core/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class AnimationDurations {

// @public
export interface AnimationsConfig {
animationsDisabled: boolean;
animationsDisabled?: boolean;
}

// @public
Expand Down
1 change: 1 addition & 0 deletions src/material/core/animation/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ ng_project(
srcs = ["animation.ts"],
deps = [
"//:node_modules/@angular/core",
"//src/cdk/layout",
],
)
15 changes: 9 additions & 6 deletions src/material/core/animation/animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {MediaMatcher} from '@angular/cdk/layout';
import {ANIMATION_MODULE_TYPE, inject, InjectionToken} from '@angular/core';

/** Object used to configure the animation in Angular Material. */
export interface AnimationsConfig {
/** Whether all animations should be disabled. */
animationsDisabled: boolean;
animationsDisabled?: boolean;
}

/** Injection token used to configure the animations in Angular Material. */
Expand Down Expand Up @@ -45,11 +46,13 @@ export class AnimationDurations {
* @docs-private
*/
export function _animationsDisabled(): boolean {
const customToken = inject(MATERIAL_ANIMATIONS, {optional: true});

if (customToken) {
return customToken.animationsDisabled;
if (
inject(MATERIAL_ANIMATIONS, {optional: true})?.animationsDisabled ||
inject(ANIMATION_MODULE_TYPE, {optional: true}) === 'NoopAnimations'
) {
return true;
}

return inject(ANIMATION_MODULE_TYPE, {optional: true}) === 'NoopAnimations';
const mediaMatcher = inject(MediaMatcher);
return mediaMatcher.matchMedia('(prefers-reduced-motion)').matches;
}
Loading