@@ -15,7 +15,6 @@ import {MdDialogContainer} from './dialog-container';
15
15
16
16
17
17
// TODO(jelbourn): resizing
18
- // TODO(jelbourn): afterOpen
19
18
20
19
// Counter for unique dialog ids.
21
20
let uniqueId = 0 ;
@@ -30,11 +29,14 @@ export class MdDialogRef<T> {
30
29
/** Whether the user is allowed to close the dialog. */
31
30
disableClose = this . _containerInstance . _config . disableClose ;
32
31
32
+ /** Subject for notifying the user that the dialog has finished opening. */
33
+ private _afterOpen = new Subject < void > ( ) ;
34
+
33
35
/** Subject for notifying the user that the dialog has finished closing. */
34
- private _afterClosed : Subject < any > = new Subject ( ) ;
36
+ private _afterClosed = new Subject < any > ( ) ;
35
37
36
38
/** Subject for notifying the user that the dialog has started closing. */
37
- private _beforeClose : Subject < any > = new Subject ( ) ;
39
+ private _beforeClose = new Subject < any > ( ) ;
38
40
39
41
/** Result to be passed to afterClosed. */
40
42
private _result : any ;
@@ -44,6 +46,16 @@ export class MdDialogRef<T> {
44
46
private _containerInstance : MdDialogContainer ,
45
47
public readonly id : string = `md-dialog-${ uniqueId ++ } ` ) {
46
48
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
47
59
RxChain . from ( _containerInstance . _animationStateChanged )
48
60
. call ( filter , event => event . phaseName === 'done' && event . toState === 'exit' )
49
61
. call ( first )
@@ -75,6 +87,13 @@ export class MdDialogRef<T> {
75
87
this . _containerInstance . _startExitAnimation ( ) ;
76
88
}
77
89
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
+
78
97
/**
79
98
* Gets an observable that is notified when the dialog is finished closing.
80
99
*/
0 commit comments