@@ -23,7 +23,7 @@ import {
23
23
NgZone ,
24
24
Renderer2 ,
25
25
ChangeDetectionStrategy ,
26
- ChangeDetectorRef ,
26
+ ChangeDetectorRef
27
27
} from '@angular/core' ;
28
28
import {
29
29
RIGHT_ARROW ,
@@ -40,7 +40,8 @@ import {of as observableOf} from 'rxjs/observable/of';
40
40
import { merge } from 'rxjs/observable/merge' ;
41
41
import { fromEvent } from 'rxjs/observable/fromEvent' ;
42
42
import { CanDisableRipple , mixinDisableRipple } from '../core/common-behaviors/disable-ripple' ;
43
-
43
+ import { RxChain , debounceTime } from '@angular/cdk/rxjs' ;
44
+ import { Platform } from '@angular/cdk/platform' ;
44
45
45
46
/**
46
47
* The directions that scrolling can go in when the header's tabs exceed the header width. 'After'
@@ -121,6 +122,9 @@ export class MdTabHeader extends _MdTabHeaderMixinBase
121
122
122
123
private _selectedIndex : number = 0 ;
123
124
125
+ /** subscription for the window resize handler */
126
+ private _resizeSubscription : Subscription | null ;
127
+
124
128
/** The index of the active tab. */
125
129
@Input ( )
126
130
get selectedIndex ( ) : number { return this . _selectedIndex ; }
@@ -141,8 +145,16 @@ export class MdTabHeader extends _MdTabHeaderMixinBase
141
145
private _ngZone : NgZone ,
142
146
private _renderer : Renderer2 ,
143
147
private _changeDetectorRef : ChangeDetectorRef ,
144
- @Optional ( ) private _dir : Directionality ) {
148
+ @Optional ( ) private _dir : Directionality ,
149
+ platform : Platform ) {
145
150
super ( ) ;
151
+
152
+ if ( platform . isBrowser ) {
153
+ // TODO: Add library level window listener https://goo.gl/y25X5M
154
+ this . _resizeSubscription = RxChain . from ( fromEvent ( window , 'resize' ) )
155
+ . call ( debounceTime , 150 )
156
+ . subscribe ( ( ) => this . _checkPaginationEnabled ( ) ) ;
157
+ }
146
158
}
147
159
148
160
ngAfterContentChecked ( ) : void {
@@ -208,6 +220,11 @@ export class MdTabHeader extends _MdTabHeaderMixinBase
208
220
this . _realignInkBar . unsubscribe ( ) ;
209
221
this . _realignInkBar = null ;
210
222
}
223
+
224
+ if ( this . _resizeSubscription ) {
225
+ this . _resizeSubscription . unsubscribe ( ) ;
226
+ this . _resizeSubscription = null ;
227
+ }
211
228
}
212
229
213
230
/**
0 commit comments