@@ -15,7 +15,6 @@ import {MdDialogContainer} from './dialog-container';
1515
1616
1717// TODO(jelbourn): resizing
18- // TODO(jelbourn): afterOpen
1918
2019// Counter for unique dialog ids.
2120let uniqueId = 0 ;
@@ -30,11 +29,14 @@ export class MdDialogRef<T> {
3029 /** Whether the user is allowed to close the dialog. */
3130 disableClose = this . _containerInstance . _config . disableClose ;
3231
32+ /** Subject for notifying the user that the dialog has finished opening. */
33+ private _afterOpen = new Subject < void > ( ) ;
34+
3335 /** Subject for notifying the user that the dialog has finished closing. */
34- private _afterClosed : Subject < any > = new Subject ( ) ;
36+ private _afterClosed = new Subject < any > ( ) ;
3537
3638 /** Subject for notifying the user that the dialog has started closing. */
37- private _beforeClose : Subject < any > = new Subject ( ) ;
39+ private _beforeClose = new Subject < any > ( ) ;
3840
3941 /** Result to be passed to afterClosed. */
4042 private _result : any ;
@@ -44,6 +46,16 @@ export class MdDialogRef<T> {
4446 private _containerInstance : MdDialogContainer ,
4547 public readonly id : string = `md-dialog-${ uniqueId ++ } ` ) {
4648
49+ // Emit when opening animation completes
50+ RxChain . from ( _containerInstance . _animationStateChanged )
51+ . call ( filter , event => event . phaseName === 'done' && event . toState === 'enter' )
52+ . call ( first )
53+ . subscribe ( ( ) => {
54+ this . _afterOpen . next ( ) ;
55+ this . _afterOpen . complete ( ) ;
56+ } ) ;
57+
58+ // Dispose overlay when closing animation is complete
4759 RxChain . from ( _containerInstance . _animationStateChanged )
4860 . call ( filter , event => event . phaseName === 'done' && event . toState === 'exit' )
4961 . call ( first )
@@ -75,6 +87,13 @@ export class MdDialogRef<T> {
7587 this . _containerInstance . _startExitAnimation ( ) ;
7688 }
7789
90+ /**
91+ * Gets an observable that is notified when the dialog is finished opening.
92+ */
93+ afterOpen ( ) : Observable < void > {
94+ return this . _afterOpen . asObservable ( ) ;
95+ }
96+
7897 /**
7998 * Gets an observable that is notified when the dialog is finished closing.
8099 */
0 commit comments