@@ -13,6 +13,8 @@ import {Subject} from 'rxjs/Subject';
13
13
export class OverlayRef implements PortalHost {
14
14
private _backdropElement : HTMLElement = null ;
15
15
private _backdropClick : Subject < any > = new Subject ( ) ;
16
+ private _onAttach = new Subject < void > ( ) ;
17
+ private _onDetach = new Subject < void > ( ) ;
16
18
17
19
constructor (
18
20
private _portalHost : PortalHost ,
@@ -41,6 +43,7 @@ export class OverlayRef implements PortalHost {
41
43
this . updateSize ( ) ;
42
44
this . updateDirection ( ) ;
43
45
this . updatePosition ( ) ;
46
+ this . _onAttach . next ( ) ;
44
47
this . _state . scrollStrategy . enable ( ) ;
45
48
46
49
// Enable pointer events for the overlay pane element.
@@ -65,6 +68,7 @@ export class OverlayRef implements PortalHost {
65
68
// pointer events therefore. Depends on the position strategy and the applied pane boundaries.
66
69
this . _togglePointerEvents ( false ) ;
67
70
this . _state . scrollStrategy . disable ( ) ;
71
+ this . _onDetach . next ( ) ;
68
72
69
73
return this . _portalHost . detach ( ) ;
70
74
}
@@ -80,6 +84,9 @@ export class OverlayRef implements PortalHost {
80
84
this . detachBackdrop ( ) ;
81
85
this . _portalHost . dispose ( ) ;
82
86
this . _state . scrollStrategy . disable ( ) ;
87
+ this . _onDetach . next ( ) ;
88
+ this . _onDetach . complete ( ) ;
89
+ this . _onAttach . complete ( ) ;
83
90
}
84
91
85
92
/**
@@ -96,6 +103,16 @@ export class OverlayRef implements PortalHost {
96
103
return this . _backdropClick . asObservable ( ) ;
97
104
}
98
105
106
+ /** Returns an observable that emits when the overlay has been attached. */
107
+ onAttach ( ) : Observable < void > {
108
+ return this . _onAttach . asObservable ( ) ;
109
+ }
110
+
111
+ /** Returns an observable that emits when the overlay has been detached. */
112
+ onDetach ( ) : Observable < void > {
113
+ return this . _onDetach . asObservable ( ) ;
114
+ }
115
+
99
116
/**
100
117
* Gets the current state config of the overlay.
101
118
*/
0 commit comments