Skip to content

Commit 804f4c0

Browse files
crisbetokara
authored andcommitted
fix(sidenav): first animation not working in Angular 4.2+ (#5821)
Fixes #5673
1 parent 4a79dd4 commit 804f4c0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/lib/sidenav/sidenav.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ export class MdSidenav implements AfterContentInit, OnDestroy {
334334
],
335335
host: {
336336
'class': 'mat-sidenav-container',
337-
'[class.mat-sidenav-transition]': '_enableTransitions',
338337
},
339338
encapsulation: ViewEncapsulation.None,
340339
})
@@ -363,9 +362,6 @@ export class MdSidenavContainer implements AfterContentInit {
363362
private _left: MdSidenav | null;
364363
private _right: MdSidenav | null;
365364

366-
/** Whether to enable open/close trantions. */
367-
_enableTransitions = false;
368-
369365
constructor(@Optional() private _dir: Directionality, private _element: ElementRef,
370366
private _renderer: Renderer2, private _ngZone: NgZone) {
371367
// If a `Dir` directive exists up the tree, listen direction changes and update the left/right
@@ -384,8 +380,12 @@ export class MdSidenavContainer implements AfterContentInit {
384380
});
385381
this._validateDrawers();
386382

387-
// Give the view a chance to render the initial state, then enable transitions.
388-
first.call(this._ngZone.onMicrotaskEmpty).subscribe(() => this._enableTransitions = true);
383+
// Give the view a chance to render the initial state, then enable transitions. Note that we
384+
// don't use data binding, because we're not guaranteed that newer version of Angular will
385+
// re-evaluate them after we set the flag here.
386+
first.call(this._ngZone.onMicrotaskEmpty).subscribe(() => {
387+
this._renderer.addClass(this._element.nativeElement, 'mat-sidenav-transition');
388+
});
389389
}
390390

391391
/** Calls `open` of both start and end sidenavs */

0 commit comments

Comments
 (0)