@@ -13,14 +13,16 @@ import {
1313 EventEmitter ,
1414 Renderer ,
1515 ViewEncapsulation ,
16- ViewChild
16+ ViewChild ,
17+ NgZone
1718} from '@angular/core' ;
1819import { CommonModule } from '@angular/common' ;
1920import { Dir , MdError , coerceBooleanProperty , CompatibilityModule } from '../core' ;
2021import { A11yModule } from '../core/a11y/index' ;
2122import { FocusTrap } from '../core/a11y/focus-trap' ;
2223import { ESCAPE } from '../core/keyboard/keycodes' ;
2324import { OverlayModule } from '../core/overlay/overlay-directives' ;
25+ import 'rxjs/add/operator/first' ;
2426
2527
2628/** Exception thrown when two MdSidenav are matching the same side. */
@@ -321,6 +323,7 @@ export class MdSidenav implements AfterContentInit {
321323 ] ,
322324 host : {
323325 '[class.mat-sidenav-container]' : 'true' ,
326+ '[class.mat-sidenav-transition]' : '_enableTransitions' ,
324327 } ,
325328 encapsulation : ViewEncapsulation . None ,
326329} )
@@ -349,8 +352,11 @@ export class MdSidenavContainer implements AfterContentInit {
349352 private _left : MdSidenav ;
350353 private _right : MdSidenav ;
351354
355+ /** Whether to enable open/close trantions. */
356+ _enableTransitions = false ;
357+
352358 constructor ( @Optional ( ) private _dir : Dir , private _element : ElementRef ,
353- private _renderer : Renderer ) {
359+ private _renderer : Renderer , private _ngZone : NgZone ) {
354360 // If a `Dir` directive exists up the tree, listen direction changes and update the left/right
355361 // properties to point to the proper start/end.
356362 if ( _dir != null ) {
@@ -366,6 +372,9 @@ export class MdSidenavContainer implements AfterContentInit {
366372 this . _watchSidenavAlign ( sidenav ) ;
367373 } ) ;
368374 this . _validateDrawers ( ) ;
375+
376+ // Give the view a chance to render the initial state, then enable transitions.
377+ this . _ngZone . onMicrotaskEmpty . first ( ) . subscribe ( ( ) => this . _enableTransitions = true ) ;
369378 }
370379
371380 /**
0 commit comments