Skip to content

Commit 6295ff6

Browse files
committed
main - 82f0fa6 feat(material/core): handle prefers-reduced-motion automatically (#30796)
1 parent 4ee984e commit 6295ff6

File tree

89 files changed

+234
-205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+234
-205
lines changed

core/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ declare const VERSION: Version;
2626
/** Object used to configure the animation in Angular Material. */
2727
interface AnimationsConfig {
2828
/** Whether all animations should be disabled. */
29-
animationsDisabled: boolean;
29+
animationsDisabled?: boolean;
3030
}
3131
/** Injection token used to configure the animations in Angular Material. */
3232
declare const MATERIAL_ANIMATIONS: InjectionToken<AnimationsConfig>;

fesm2022/animation-89957083.mjs.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

fesm2022/animation-89957083.mjs renamed to fesm2022/animation-924dea30.mjs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { MediaMatcher } from '@angular/cdk/layout';
12
import { InjectionToken, inject, ANIMATION_MODULE_TYPE } from '@angular/core';
23

34
/** Injection token used to configure the animations in Angular Material. */
@@ -28,12 +29,13 @@ class AnimationDurations {
2829
* @docs-private
2930
*/
3031
function _animationsDisabled() {
31-
const customToken = inject(MATERIAL_ANIMATIONS, { optional: true });
32-
if (customToken) {
33-
return customToken.animationsDisabled;
32+
if (inject(MATERIAL_ANIMATIONS, { optional: true })?.animationsDisabled ||
33+
inject(ANIMATION_MODULE_TYPE, { optional: true }) === 'NoopAnimations') {
34+
return true;
3435
}
35-
return inject(ANIMATION_MODULE_TYPE, { optional: true }) === 'NoopAnimations';
36+
const mediaMatcher = inject(MediaMatcher);
37+
return mediaMatcher.matchMedia('(prefers-reduced-motion)').matches;
3638
}
3739

3840
export { AnimationCurves as A, MATERIAL_ANIMATIONS as M, _animationsDisabled as _, AnimationDurations as a };
39-
//# sourceMappingURL=animation-89957083.mjs.map
41+
//# sourceMappingURL=animation-924dea30.mjs.map

fesm2022/animation-924dea30.mjs.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fesm2022/autocomplete.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
import { M as MAT_OPTION_PARENT_COMPONENT, a as MatOption, b as MAT_OPTGROUP, c as MatOptionSelectionChange, _ as _countGroupLabelsBeforeOption, d as _getOptionScrollPosition } from './option-f73e199f.mjs';
2-
export { e as MatOptgroup, a as MatOption } from './option-f73e199f.mjs';
1+
import { M as MAT_OPTION_PARENT_COMPONENT, a as MatOption, b as MAT_OPTGROUP, c as MatOptionSelectionChange, _ as _countGroupLabelsBeforeOption, d as _getOptionScrollPosition } from './option-cca7aff4.mjs';
2+
export { e as MatOptgroup, a as MatOption } from './option-cca7aff4.mjs';
33
import * as i0 from '@angular/core';
44
import { InjectionToken, inject, ChangeDetectorRef, ElementRef, EventEmitter, booleanAttribute, TemplateRef, Component, ViewEncapsulation, ChangeDetectionStrategy, ViewChild, ContentChildren, Input, Output, Directive, forwardRef, EnvironmentInjector, ViewContainerRef, NgZone, Renderer2, afterNextRender, NgModule } from '@angular/core';
55
import { ViewportRuler, CdkScrollableModule } from '@angular/cdk/scrolling';
66
import { Overlay, OverlayConfig, OverlayModule } from '@angular/cdk/overlay';
77
import { _IdGenerator, ActiveDescendantKeyManager, removeAriaReferencedId, addAriaReferencedId } from '@angular/cdk/a11y';
88
import { Platform, _getFocusedElementPierceShadowDom, _getEventTarget } from '@angular/cdk/platform';
99
import { Subscription, Subject, merge, of, defer, Observable } from 'rxjs';
10-
import { _ as _animationsDisabled } from './animation-89957083.mjs';
10+
import { _ as _animationsDisabled } from './animation-924dea30.mjs';
1111
import { Directionality } from '@angular/cdk/bidi';
1212
import { hasModifierKey, ESCAPE, ENTER, TAB, UP_ARROW, DOWN_ARROW } from '@angular/cdk/keycodes';
1313
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
1414
import { TemplatePortal } from '@angular/cdk/portal';
1515
import { NG_VALUE_ACCESSOR } from '@angular/forms';
1616
import { filter, map, startWith, switchMap, tap, delay, take } from 'rxjs/operators';
17-
import { M as MAT_FORM_FIELD } from './form-field-362737c2.mjs';
18-
import { M as MatOptionModule } from './index-c6f98e9a.mjs';
17+
import { M as MAT_FORM_FIELD } from './form-field-1373abf0.mjs';
18+
import { M as MatOptionModule } from './index-cbd9386a.mjs';
1919
import { M as MatCommonModule } from './common-module-727dea0d.mjs';
20-
import './ripple-7f0562cc.mjs';
20+
import './ripple-df48cf18.mjs';
2121
import '@angular/cdk/coercion';
2222
import '@angular/cdk/private';
23-
import './pseudo-checkbox-eb9ea05b.mjs';
23+
import './pseudo-checkbox-5bada414.mjs';
2424
import './structural-styles-efc7816b.mjs';
2525
import '@angular/common';
2626
import '@angular/cdk/observers/private';
27-
import './index-59ddbae2.mjs';
28-
import './pseudo-checkbox-module-a5e70e5c.mjs';
27+
import './index-ac2e1e56.mjs';
28+
import './pseudo-checkbox-module-8bc38039.mjs';
2929

3030
/** Event object that is emitted when an autocomplete option is selected. */
3131
class MatAutocompleteSelectedEvent {

fesm2022/badge.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { DOCUMENT } from '@angular/common';
33
import * as i0 from '@angular/core';
44
import { Component, ViewEncapsulation, ChangeDetectionStrategy, inject, NgZone, ElementRef, Renderer2, booleanAttribute, Directive, Input, NgModule } from '@angular/core';
55
import { _CdkPrivateStyleLoader, _VisuallyHiddenLoader } from '@angular/cdk/private';
6-
import { _ as _animationsDisabled } from './animation-89957083.mjs';
6+
import { _ as _animationsDisabled } from './animation-924dea30.mjs';
77
import { M as MatCommonModule } from './common-module-727dea0d.mjs';
8+
import '@angular/cdk/layout';
89
import '@angular/cdk/bidi';
910

1011
const BADGE_CONTENT_CLASS = 'mat-badge-content';

fesm2022/badge.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fesm2022/bottom-sheet.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { CdkPortalOutlet, PortalModule } from '@angular/cdk/portal';
33
import * as i0 from '@angular/core';
44
import { EventEmitter, inject, Component, ChangeDetectionStrategy, ViewEncapsulation, InjectionToken, Injectable, NgModule } from '@angular/core';
55
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
6-
import { _ as _animationsDisabled } from './animation-89957083.mjs';
6+
import { _ as _animationsDisabled } from './animation-924dea30.mjs';
77
import { Overlay } from '@angular/cdk/overlay';
88
import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
99
import { Subject, merge } from 'rxjs';

fesm2022/button-toggle.mjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import { _CdkPrivateStyleLoader } from '@angular/cdk/private';
66
import * as i0 from '@angular/core';
77
import { InjectionToken, forwardRef, inject, ChangeDetectorRef, EventEmitter, booleanAttribute, Directive, ContentChildren, Input, Output, ElementRef, HostAttributeToken, Component, ViewEncapsulation, ChangeDetectionStrategy, ViewChild, NgModule } from '@angular/core';
88
import { NG_VALUE_ACCESSOR } from '@angular/forms';
9-
import { M as MatRipple } from './ripple-7f0562cc.mjs';
10-
import { M as MatPseudoCheckbox } from './pseudo-checkbox-eb9ea05b.mjs';
11-
import { _ as _animationsDisabled } from './animation-89957083.mjs';
9+
import { M as MatRipple } from './ripple-df48cf18.mjs';
10+
import { M as MatPseudoCheckbox } from './pseudo-checkbox-5bada414.mjs';
11+
import { _ as _animationsDisabled } from './animation-924dea30.mjs';
1212
import { _ as _StructuralStylesLoader } from './structural-styles-efc7816b.mjs';
1313
import { M as MatCommonModule } from './common-module-727dea0d.mjs';
14-
import { M as MatRippleModule } from './index-59ddbae2.mjs';
14+
import { M as MatRippleModule } from './index-ac2e1e56.mjs';
1515
import '@angular/cdk/platform';
1616
import '@angular/cdk/coercion';
17+
import '@angular/cdk/layout';
1718

1819
/**
1920
* Injection token that can be used to configure the

fesm2022/button-toggle.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)