Skip to content

fix(sidenav): animate sidenav on open/close changes #6064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 3 additions & 7 deletions src/lib/sidenav/sidenav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,6 @@ export class MdSidenavContainer implements AfterContentInit {
this._watchSidenavAlign(sidenav);
});
this._validateDrawers();

// 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 All @@ -409,6 +402,9 @@ export class MdSidenavContainer implements AfterContentInit {
*/
private _watchSidenavToggle(sidenav: MdSidenav): void {
merge(sidenav.onOpenStart, sidenav.onCloseStart).subscribe(() => {
// Set the transition class on the container so that the animations occur. This should not
// be set initially because animations should only be triggered via a change in state.
this._renderer.addClass(this._element.nativeElement, 'mat-sidenav-transition');
this._changeDetectorRef.markForCheck();
});

Expand Down