@@ -17,6 +17,7 @@ import {
17
17
ScrollingVisibility ,
18
18
} from './connected-position' ;
19
19
import { Subject } from 'rxjs/Subject' ;
20
+ import { Subscription } from 'rxjs/Subscription' ;
20
21
import { Observable } from 'rxjs/Observable' ;
21
22
import { Scrollable } from '@angular/cdk/scrolling' ;
22
23
import { isElementScrolledOutsideView , isElementClippedByScrolling } from './scroll-clip' ;
@@ -35,6 +36,7 @@ export class ConnectedPositionStrategy implements PositionStrategy {
35
36
/** The overlay to which this strategy is attached. */
36
37
private _overlayRef : OverlayRef ;
37
38
39
+ /** Layout direction of the position strategy. */
38
40
private _dir = 'ltr' ;
39
41
40
42
/** The offset in pixels for the overlay connection point on the x-axis */
@@ -46,6 +48,9 @@ export class ConnectedPositionStrategy implements PositionStrategy {
46
48
/** The Scrollable containers used to check scrollable view properties on position change. */
47
49
private scrollables : Scrollable [ ] = [ ] ;
48
50
51
+ /** Subscription to viewport resize events. */
52
+ private _resizeSubscription = Subscription . EMPTY ;
53
+
49
54
/** Whether the we're dealing with an RTL context */
50
55
get _isRtl ( ) {
51
56
return this . _dir === 'rtl' ;
@@ -88,10 +93,19 @@ export class ConnectedPositionStrategy implements PositionStrategy {
88
93
attach ( overlayRef : OverlayRef ) : void {
89
94
this . _overlayRef = overlayRef ;
90
95
this . _pane = overlayRef . overlayElement ;
96
+ this . _resizeSubscription . unsubscribe ( ) ;
97
+ this . _resizeSubscription = this . _viewportRuler . change ( ) . subscribe ( ( ) => this . apply ( ) ) ;
91
98
}
92
99
93
100
/** Performs any cleanup after the element is destroyed. */
94
- dispose ( ) { }
101
+ dispose ( ) {
102
+ this . _resizeSubscription . unsubscribe ( ) ;
103
+ }
104
+
105
+ /** @docs -private */
106
+ detach ( ) {
107
+ this . _resizeSubscription . unsubscribe ( ) ;
108
+ }
95
109
96
110
/**
97
111
* Updates the position of the overlay element, using whichever preferred position relative
0 commit comments