Skip to content
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

fix(sidenav): fix animation issue for initially open sidenav #3045

Merged
merged 3 commits into from
Feb 15, 2017
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
24 changes: 13 additions & 11 deletions src/lib/sidenav/sidenav-transitions.scss
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
// Separate transitions to be able to disable them in unit tests by omitting this file.
@import '../core/style/variables';

.mat-sidenav {
transition: transform $swift-ease-out-duration $swift-ease-out-timing-function;
}
.mat-sidenav-transition {
.mat-sidenav {
transition: transform $swift-ease-out-duration $swift-ease-out-timing-function;
}

.mat-sidenav-content {
transition: {
duration: $swift-ease-out-duration;
timing-function: $swift-ease-out-timing-function;
property: transform, margin-left, margin-right;
.mat-sidenav-content {
transition: {
duration: $swift-ease-out-duration;
timing-function: $swift-ease-out-timing-function;
property: transform, margin-left, margin-right;
}
}
}

.mat-sidenav-backdrop.mat-sidenav-shown {
transition: background-color $swift-ease-out-duration $swift-ease-out-timing-function;
.mat-sidenav-backdrop.mat-sidenav-shown {
transition: background-color $swift-ease-out-duration $swift-ease-out-timing-function;
}
}
13 changes: 11 additions & 2 deletions src/lib/sidenav/sidenav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ import {
EventEmitter,
Renderer,
ViewEncapsulation,
ViewChild
ViewChild,
NgZone
} from '@angular/core';
import {CommonModule} from '@angular/common';
import {Dir, MdError, coerceBooleanProperty, CompatibilityModule} from '../core';
import {A11yModule} from '../core/a11y/index';
import {FocusTrap} from '../core/a11y/focus-trap';
import {ESCAPE} from '../core/keyboard/keycodes';
import {OverlayModule} from '../core/overlay/overlay-directives';
import 'rxjs/add/operator/first';


/** Exception thrown when two MdSidenav are matching the same side. */
Expand Down Expand Up @@ -321,6 +323,7 @@ export class MdSidenav implements AfterContentInit {
],
host: {
'[class.mat-sidenav-container]': 'true',
'[class.mat-sidenav-transition]': '_enableTransitions',
},
encapsulation: ViewEncapsulation.None,
})
Expand Down Expand Up @@ -349,8 +352,11 @@ export class MdSidenavContainer implements AfterContentInit {
private _left: MdSidenav;
private _right: MdSidenav;

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

constructor(@Optional() private _dir: Dir, private _element: ElementRef,
private _renderer: Renderer) {
private _renderer: Renderer, private _ngZone: NgZone) {
// If a `Dir` directive exists up the tree, listen direction changes and update the left/right
// properties to point to the proper start/end.
if (_dir != null) {
Expand All @@ -366,6 +372,9 @@ export class MdSidenavContainer implements AfterContentInit {
this._watchSidenavAlign(sidenav);
});
this._validateDrawers();

// Give the view a chance to render the initial state, then enable transitions.
this._ngZone.onMicrotaskEmpty.first().subscribe(() => this._enableTransitions = true);
}

/**
Expand Down