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
1 change: 1 addition & 0 deletions goldens/cdk/dialog/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export class DialogConfig<D = unknown, R = unknown, C extends BasePortalOutlet =
};
data?: D | null;
direction?: Direction;
disableAnimations?: boolean;
disableClose?: boolean;
hasBackdrop?: boolean;
height?: string;
Expand Down
1 change: 1 addition & 0 deletions goldens/cdk/overlay/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ export class OverlayConfig {
constructor(config?: OverlayConfig);
backdropClass?: string | string[];
direction?: Direction | Directionality;
disableAnimations?: boolean;
disposeOnNavigation?: boolean;
hasBackdrop?: boolean;
height?: number | string;
Expand Down
2 changes: 0 additions & 2 deletions goldens/material/checkbox/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ export class MatCheckbox implements AfterViewInit, OnChanges, ControlValueAccess
indeterminateToChecked: string;
indeterminateToUnchecked: string;
};
// (undocumented)
_animationMode?: "NoopAnimations" | "BrowserAnimations" | null | undefined;
ariaControls: string;
ariaDescribedby: string;
ariaExpanded: boolean;
Expand Down
5 changes: 4 additions & 1 deletion goldens/material/core/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export class AnimationDurations {
static EXITING: string;
}

// @public
export function _animationsDisabled(): boolean;

// @public
export function _countGroupLabelsBeforeOption(optionIndex: number, options: QueryList<MatOption>, optionGroups: QueryList<MatOptgroup>): number;

Expand Down Expand Up @@ -318,7 +321,7 @@ export class MatOptionSelectionChange<T = any> {
export class MatPseudoCheckbox {
constructor(...args: unknown[]);
// (undocumented)
_animationMode?: "NoopAnimations" | "BrowserAnimations" | null | undefined;
_animationsDisabled: boolean;
appearance: 'minimal' | 'full';
disabled: boolean;
state: MatPseudoCheckboxState;
Expand Down
2 changes: 0 additions & 2 deletions goldens/material/progress-bar/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ export function MAT_PROGRESS_BAR_LOCATION_FACTORY(): MatProgressBarLocation;
export class MatProgressBar implements AfterViewInit, OnDestroy {
constructor(...args: unknown[]);
readonly animationEnd: EventEmitter<ProgressAnimationEnd>;
// (undocumented)
_animationMode?: "NoopAnimations" | "BrowserAnimations" | null | undefined;
get bufferValue(): number;
set bufferValue(v: number);
get color(): string | null | undefined;
Expand Down
2 changes: 1 addition & 1 deletion goldens/material/sort/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export interface MatSortDefaultOptions {
export class MatSortHeader implements MatSortable, OnDestroy, OnInit, AfterViewInit {
constructor(...args: unknown[]);
// (undocumented)
protected _animationModule: "NoopAnimations" | "BrowserAnimations" | null;
protected _animationsDisabled: boolean;
arrowPosition: SortHeaderArrowPosition;
// (undocumented)
_columnDef: MatSortHeaderColumnDef | null;
Expand Down
4 changes: 2 additions & 2 deletions goldens/material/tabs/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export abstract class MatPaginatedTabHeader implements AfterContentChecked, Afte
constructor(...args: unknown[]);
_alignInkBarToSelectedTab(): void;
// (undocumented)
_animationMode: "NoopAnimations" | "BrowserAnimations" | null;
_animationsDisabled: boolean;
// (undocumented)
protected _changeDetectorRef: ChangeDetectorRef;
_checkPaginationEnabled(): void;
Expand Down Expand Up @@ -246,7 +246,7 @@ export class MatTabGroup implements AfterViewInit, AfterContentInit, AfterConten
get animationDuration(): string;
set animationDuration(value: string | number);
// (undocumented)
_animationMode: "NoopAnimations" | "BrowserAnimations" | null;
_animationsDisabled: boolean;
ariaLabel: string;
ariaLabelledby: string;
// @deprecated
Expand Down
5 changes: 5 additions & 0 deletions src/cdk/dialog/dialog-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ export class DialogConfig<D = unknown, R = unknown, C extends BasePortalOutlet =
*/
closeOnOverlayDetachments?: boolean = true;

/**
* Whether the built-in overlay animations should be disabled.
*/
disableAnimations?: boolean = false;

/**
* Providers that will be exposed to the contents of the dialog. Can also
* be provided as a function in order to generate the providers lazily.
Expand Down
1 change: 1 addition & 0 deletions src/cdk/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export class Dialog implements OnDestroy {
width: config.width,
height: config.height,
disposeOnNavigation: config.closeOnNavigation,
disableAnimations: config.disableAnimations,
});

if (config.backdropClass) {
Expand Down
3 changes: 3 additions & 0 deletions src/cdk/overlay/overlay-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export class OverlayConfig {
/** Custom class to add to the backdrop */
backdropClass?: string | string[] = 'cdk-overlay-dark-backdrop';

/** Whether to disable any built-in animations. */
disableAnimations?: boolean;

/** The width of the overlay panel. If a number is provided, pixel units are assumed. */
width?: number | string;

Expand Down
2 changes: 1 addition & 1 deletion src/cdk/overlay/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class Overlay {
this._document,
this._location,
this._outsideClickDispatcher,
this._animationsModuleType === 'NoopAnimations',
config?.disableAnimations ?? this._animationsModuleType === 'NoopAnimations',
this._injector.get(EnvironmentInjector),
this._renderer,
);
Expand Down
40 changes: 0 additions & 40 deletions src/dev-app/checkbox/checkbox-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -255,46 +255,6 @@ <h5>Click action: noop</h5>
}
</mat-checkbox>
</div>
<div animationsNoop>
<h5>No animations</h5>
<mat-checkbox
[required]="demoRequired"
[labelPosition]="demoLabelAfter ? 'after' : 'before'"
[aria-label]="demoLabel"
[aria-labelledby]="demoLabelledBy"
[color]="demoColor"
[disableRipple]="demoDisableRipple"
[id]="demoId"
[name]="demoName"
[value]="demoValue"
[checked]="demoChecked"
[disabled]="demoDisabled"
[indeterminate]="demoIndeterminate"
(change)="demoChecked = $event.checked"
(indeterminateChange)="demoIndeterminate = $event">
@if (!demoHideLabel) {
Checkbox w/ [checked] & (change)
}
</mat-checkbox>
<mat-checkbox
[required]="demoRequired"
[labelPosition]="demoLabelAfter ? 'after' : 'before'"
[aria-label]="demoLabel"
[aria-labelledby]="demoLabelledBy"
[color]="demoColor"
[disableRipple]="demoDisableRipple"
[id]="demoId"
[name]="demoName"
[value]="demoValue"
[disabled]="demoDisabled"
[indeterminate]="demoIndeterminate"
[(ngModel)]="demoChecked"
(indeterminateChange)="demoIndeterminate = $event">
@if (!demoHideLabel) {
Checkbox w/ [(ngModel)]
}
</mat-checkbox>
</div>
</div>

<p>
Expand Down
9 changes: 1 addition & 8 deletions src/dev-app/checkbox/checkbox-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import {ANIMATION_MODULE_TYPE, ChangeDetectionStrategy, Component, Directive} from '@angular/core';
import {ChangeDetectionStrategy, Component, Directive} from '@angular/core';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {MAT_CHECKBOX_DEFAULT_OPTIONS, MatCheckboxModule} from '@angular/material/checkbox';
import {MatPseudoCheckboxModule, ThemePalette} from '@angular/material/core';
Expand All @@ -32,12 +32,6 @@ export class ClickActionNoop {}
})
export class ClickActionCheck {}

@Directive({
selector: '[animationsNoop]',
providers: [{provide: ANIMATION_MODULE_TYPE, useValue: 'NoopAnimations'}],
})
export class AnimationsNoop {}

@Component({
selector: 'mat-checkbox-demo-nested-checklist',
styles: `
Expand Down Expand Up @@ -107,7 +101,6 @@ export class MatCheckboxDemoNestedChecklist {
MatCheckboxDemoNestedChecklist,
ClickActionNoop,
ClickActionCheck,
AnimationsNoop,
MatTooltip,
],
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down
3 changes: 3 additions & 0 deletions src/material/autocomplete/autocomplete-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
import {
MatOption,
MatOptionSelectionChange,
_animationsDisabled,
_countGroupLabelsBeforeOption,
_getOptionScrollPosition,
} from '../core';
Expand Down Expand Up @@ -149,6 +150,7 @@ export class MatAutocompleteTrigger
private _viewportRuler = inject(ViewportRuler);
private _scrollStrategy = inject(MAT_AUTOCOMPLETE_SCROLL_STRATEGY);
private _renderer = inject(Renderer2);
private _animationsDisabled = _animationsDisabled();
private _defaults = inject<MatAutocompleteDefaultOptions | null>(
MAT_AUTOCOMPLETE_DEFAULT_OPTIONS,
{optional: true},
Expand Down Expand Up @@ -903,6 +905,7 @@ export class MatAutocompleteTrigger
hasBackdrop: this._defaults?.hasBackdrop,
backdropClass: this._defaults?.backdropClass,
panelClass: this._defaults?.overlayPanelClass,
disableAnimations: this._animationsDisabled,
});
}

Expand Down
5 changes: 2 additions & 3 deletions src/material/autocomplete/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import {
ANIMATION_MODULE_TYPE,
AfterContentInit,
ChangeDetectionStrategy,
ChangeDetectorRef,
Expand All @@ -27,6 +26,7 @@ import {
inject,
} from '@angular/core';
import {
_animationsDisabled,
MAT_OPTGROUP,
MAT_OPTION_PARENT_COMPONENT,
MatOptgroup,
Expand Down Expand Up @@ -124,8 +124,7 @@ export class MatAutocomplete implements AfterContentInit, OnDestroy {
private _changeDetectorRef = inject(ChangeDetectorRef);
private _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
protected _defaults = inject<MatAutocompleteDefaultOptions>(MAT_AUTOCOMPLETE_DEFAULT_OPTIONS);
protected _animationsDisabled =
inject(ANIMATION_MODULE_TYPE, {optional: true}) === 'NoopAnimations';
protected _animationsDisabled = _animationsDisabled();
private _activeOptionChanges = Subscription.EMPTY;

/** Manages active item in option list based on key events. */
Expand Down
9 changes: 4 additions & 5 deletions src/material/badge/badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ import {
OnInit,
Renderer2,
ViewEncapsulation,
ANIMATION_MODULE_TYPE,
} from '@angular/core';
import {ThemePalette} from '../core';
import {_animationsDisabled, ThemePalette} from '../core';
import {_CdkPrivateStyleLoader, _VisuallyHiddenLoader} from '@angular/cdk/private';

/** Allowed position options for matBadgePosition */
Expand Down Expand Up @@ -76,7 +75,7 @@ export class MatBadge implements OnInit, OnDestroy {
private _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
private _ariaDescriber = inject(AriaDescriber);
private _renderer = inject(Renderer2);
private _animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true});
private _animationsDisabled = _animationsDisabled();
private _idGenerator = inject(_IdGenerator);

/**
Expand Down Expand Up @@ -240,14 +239,14 @@ export class MatBadge implements OnInit, OnDestroy {
badgeElement.setAttribute('aria-hidden', 'true');
badgeElement.classList.add(BADGE_CONTENT_CLASS);

if (this._animationMode === 'NoopAnimations') {
if (this._animationsDisabled) {
badgeElement.classList.add('_mat-animation-noopable');
}

this._elementRef.nativeElement.appendChild(badgeElement);

// animate in after insertion
if (typeof requestAnimationFrame === 'function' && this._animationMode !== 'NoopAnimations') {
if (typeof requestAnimationFrame === 'function' && !this._animationsDisabled) {
this._ngZone.runOutsideAngular(() => {
requestAnimationFrame(() => {
badgeElement.classList.add(activeClass);
Expand Down
5 changes: 2 additions & 3 deletions src/material/bottom-sheet/bottom-sheet-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import {CdkDialogContainer} from '@angular/cdk/dialog';
import {BreakpointObserver, Breakpoints} from '@angular/cdk/layout';
import {
ANIMATION_MODULE_TYPE,
ChangeDetectionStrategy,
Component,
EventEmitter,
Expand All @@ -19,6 +18,7 @@ import {
} from '@angular/core';
import {Subscription} from 'rxjs';
import {CdkPortalOutlet} from '@angular/cdk/portal';
import {_animationsDisabled} from '../core';

const ENTER_ANIMATION = '_mat-bottom-sheet-enter';
const EXIT_ANIMATION = '_mat-bottom-sheet-exit';
Expand Down Expand Up @@ -54,8 +54,7 @@ const EXIT_ANIMATION = '_mat-bottom-sheet-exit';
})
export class MatBottomSheetContainer extends CdkDialogContainer implements OnDestroy {
private _breakpointSubscription: Subscription;
protected _animationsDisabled =
inject(ANIMATION_MODULE_TYPE, {optional: true}) === 'NoopAnimations';
protected _animationsDisabled = _animationsDisabled();

/** The state of the bottom sheet animations. */
_animationState: 'void' | 'visible' | 'hidden' = 'void';
Expand Down
3 changes: 3 additions & 0 deletions src/material/bottom-sheet/bottom-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {Injectable, TemplateRef, InjectionToken, OnDestroy, inject} from '@angul
import {MAT_BOTTOM_SHEET_DATA, MatBottomSheetConfig} from './bottom-sheet-config';
import {MatBottomSheetContainer} from './bottom-sheet-container';
import {MatBottomSheetRef} from './bottom-sheet-ref';
import {_animationsDisabled} from '../core';

/** Injection token that can be used to specify default bottom sheet options. */
export const MAT_BOTTOM_SHEET_DEFAULT_OPTIONS = new InjectionToken<MatBottomSheetConfig>(
Expand All @@ -26,6 +27,7 @@ export const MAT_BOTTOM_SHEET_DEFAULT_OPTIONS = new InjectionToken<MatBottomShee
export class MatBottomSheet implements OnDestroy {
private _overlay = inject(Overlay);
private _parentBottomSheet = inject(MatBottomSheet, {optional: true, skipSelf: true});
private _animationsDisabled = _animationsDisabled();
private _defaultOptions = inject<MatBottomSheetConfig>(MAT_BOTTOM_SHEET_DEFAULT_OPTIONS, {
optional: true,
});
Expand Down Expand Up @@ -89,6 +91,7 @@ export class MatBottomSheet implements OnDestroy {
container: MatBottomSheetContainer,
scrollStrategy: _config.scrollStrategy || this._overlay.scrollStrategies.block(),
positionStrategy: this._overlay.position().global().centerHorizontally().bottom('0'),
disableAnimations: this._animationsDisabled,
templateContext: () => ({bottomSheetRef: ref}),
providers: (cdkRef, _cdkConfig, container) => {
ref = new MatBottomSheetRef(cdkRef, _config, container as MatBottomSheetContainer);
Expand Down
7 changes: 3 additions & 4 deletions src/material/button-toggle/button-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {_CdkPrivateStyleLoader} from '@angular/cdk/private';
import {
AfterContentInit,
AfterViewInit,
ANIMATION_MODULE_TYPE,
booleanAttribute,
ChangeDetectionStrategy,
ChangeDetectorRef,
Expand All @@ -36,7 +35,7 @@ import {
ViewEncapsulation,
} from '@angular/core';
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
import {_StructuralStylesLoader, MatPseudoCheckbox, MatRipple} from '../core';
import {_animationsDisabled, _StructuralStylesLoader, MatPseudoCheckbox, MatRipple} from '../core';

/**
* @deprecated No longer used.
Expand Down Expand Up @@ -577,7 +576,7 @@ export class MatButtonToggle implements OnInit, AfterViewInit, OnDestroy {
private _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
private _focusMonitor = inject(FocusMonitor);
private _idGenerator = inject(_IdGenerator);
private _animationMode = inject(ANIMATION_MODULE_TYPE, {optional: true});
private _animationDisabled = _animationsDisabled();
private _checked = false;

/**
Expand Down Expand Up @@ -721,7 +720,7 @@ export class MatButtonToggle implements OnInit, AfterViewInit, OnDestroy {
// 1. We don't want the animation to fire on the first render for pre-checked toggles so we
// delay adding the class until the view is rendered.
// 2. We don't want animation if the `NoopAnimationsModule` is provided.
if (this._animationMode !== 'NoopAnimations') {
if (!this._animationDisabled) {
this._elementRef.nativeElement.classList.add('mat-button-toggle-animations-enabled');
}

Expand Down
Loading
Loading