Skip to content

Commit cc1b322

Browse files
authored
fix(material/dialog): exit animation duration not being picked up (#27372)
Fixes that the dialog wasn't using the specified exit animation duration.
1 parent d7d8526 commit cc1b322

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/material/dialog/dialog-container.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ export class MatDialogContainer extends _MatDialogContainerBase implements OnDes
158158
/** Host element of the dialog container component. */
159159
private _hostElement: HTMLElement = this._elementRef.nativeElement;
160160
/** Duration of the dialog open animation. */
161-
private _openAnimationDuration = this._animationsEnabled
161+
private _enterAnimationDuration = this._animationsEnabled
162162
? parseCssTime(this._config.enterAnimationDuration) ?? OPEN_ANIMATION_DURATION
163163
: 0;
164164
/** Duration of the dialog close animation. */
165-
private _closeAnimationDuration = this._animationsEnabled
165+
private _exitAnimationDuration = this._animationsEnabled
166166
? parseCssTime(this._config.exitAnimationDuration) ?? CLOSE_ANIMATION_DURATION
167167
: 0;
168168
/** Current timer for dialog animations. */
@@ -218,19 +218,19 @@ export class MatDialogContainer extends _MatDialogContainerBase implements OnDes
218218

219219
/** Starts the dialog open animation if enabled. */
220220
private _startOpenAnimation() {
221-
this._animationStateChanged.emit({state: 'opening', totalTime: this._openAnimationDuration});
221+
this._animationStateChanged.emit({state: 'opening', totalTime: this._enterAnimationDuration});
222222

223223
if (this._animationsEnabled) {
224224
this._hostElement.style.setProperty(
225225
TRANSITION_DURATION_PROPERTY,
226-
`${this._openAnimationDuration}ms`,
226+
`${this._enterAnimationDuration}ms`,
227227
);
228228

229229
// We need to give the `setProperty` call from above some time to be applied.
230230
// One would expect that the open class is added once the animation finished, but MDC
231231
// uses the open class in combination with the opening class to start the animation.
232232
this._requestAnimationFrame(() => this._hostElement.classList.add(OPENING_CLASS, OPEN_CLASS));
233-
this._waitForAnimationToComplete(this._openAnimationDuration, this._finishDialogOpen);
233+
this._waitForAnimationToComplete(this._enterAnimationDuration, this._finishDialogOpen);
234234
} else {
235235
this._hostElement.classList.add(OPEN_CLASS);
236236
// Note: We could immediately finish the dialog opening here with noop animations,
@@ -246,18 +246,18 @@ export class MatDialogContainer extends _MatDialogContainerBase implements OnDes
246246
* called by the dialog ref.
247247
*/
248248
_startExitAnimation(): void {
249-
this._animationStateChanged.emit({state: 'closing', totalTime: this._closeAnimationDuration});
249+
this._animationStateChanged.emit({state: 'closing', totalTime: this._exitAnimationDuration});
250250
this._hostElement.classList.remove(OPEN_CLASS);
251251

252252
if (this._animationsEnabled) {
253253
this._hostElement.style.setProperty(
254254
TRANSITION_DURATION_PROPERTY,
255-
`${this._openAnimationDuration}ms`,
255+
`${this._exitAnimationDuration}ms`,
256256
);
257257

258258
// We need to give the `setProperty` call from above some time to be applied.
259259
this._requestAnimationFrame(() => this._hostElement.classList.add(CLOSING_CLASS));
260-
this._waitForAnimationToComplete(this._closeAnimationDuration, this._finishDialogClose);
260+
this._waitForAnimationToComplete(this._exitAnimationDuration, this._finishDialogClose);
261261
} else {
262262
// This subscription to the `OverlayRef#backdropClick` observable in the `DialogRef` is
263263
// set up before any user can subscribe to the backdrop click. The subscription triggers
@@ -286,7 +286,7 @@ export class MatDialogContainer extends _MatDialogContainerBase implements OnDes
286286
*/
287287
private _finishDialogOpen = () => {
288288
this._clearAnimationClasses();
289-
this._openAnimationDone(this._openAnimationDuration);
289+
this._openAnimationDone(this._enterAnimationDuration);
290290
};
291291

292292
/**
@@ -295,7 +295,7 @@ export class MatDialogContainer extends _MatDialogContainerBase implements OnDes
295295
*/
296296
private _finishDialogClose = () => {
297297
this._clearAnimationClasses();
298-
this._animationStateChanged.emit({state: 'closed', totalTime: this._closeAnimationDuration});
298+
this._animationStateChanged.emit({state: 'closed', totalTime: this._exitAnimationDuration});
299299
};
300300

301301
/** Clears all dialog animation classes. */

0 commit comments

Comments
 (0)