Skip to content

Commit

Permalink
fix(sidenav): first animation not working in Angular 4.2+ (#5821)
Browse files Browse the repository at this point in the history
Fixes #5673
  • Loading branch information
crisbeto authored and kara committed Jul 20, 2017
1 parent 4a79dd4 commit 804f4c0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lib/sidenav/sidenav.ts
Expand Up @@ -334,7 +334,6 @@ export class MdSidenav implements AfterContentInit, OnDestroy {
],
host: {
'class': 'mat-sidenav-container',
'[class.mat-sidenav-transition]': '_enableTransitions',
},
encapsulation: ViewEncapsulation.None,
})
Expand Down Expand Up @@ -363,9 +362,6 @@ export class MdSidenavContainer implements AfterContentInit {
private _left: MdSidenav | null;
private _right: MdSidenav | null;

/** Whether to enable open/close trantions. */
_enableTransitions = false;

constructor(@Optional() private _dir: Directionality, private _element: ElementRef,
private _renderer: Renderer2, private _ngZone: NgZone) {
// If a `Dir` directive exists up the tree, listen direction changes and update the left/right
Expand All @@ -384,8 +380,12 @@ export class MdSidenavContainer implements AfterContentInit {
});
this._validateDrawers();

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

/** Calls `open` of both start and end sidenavs */
Expand Down

0 comments on commit 804f4c0

Please sign in to comment.