@@ -23,7 +23,7 @@ import {
2323 NgZone ,
2424 Renderer2 ,
2525 ChangeDetectionStrategy ,
26- ChangeDetectorRef ,
26+ ChangeDetectorRef
2727} from '@angular/core' ;
2828import {
2929 RIGHT_ARROW ,
@@ -40,7 +40,8 @@ import {of as observableOf} from 'rxjs/observable/of';
4040import { merge } from 'rxjs/observable/merge' ;
4141import { fromEvent } from 'rxjs/observable/fromEvent' ;
4242import { CanDisableRipple , mixinDisableRipple } from '../core/common-behaviors/disable-ripple' ;
43-
43+ import { RxChain , debounceTime } from '@angular/cdk/rxjs' ;
44+ import { Platform } from '@angular/cdk/platform' ;
4445
4546/**
4647 * 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
121122
122123 private _selectedIndex : number = 0 ;
123124
125+ /** subscription for the window resize handler */
126+ private _resizeSubscription : Subscription | null ;
127+
124128 /** The index of the active tab. */
125129 @Input ( )
126130 get selectedIndex ( ) : number { return this . _selectedIndex ; }
@@ -141,8 +145,16 @@ export class MdTabHeader extends _MdTabHeaderMixinBase
141145 private _ngZone : NgZone ,
142146 private _renderer : Renderer2 ,
143147 private _changeDetectorRef : ChangeDetectorRef ,
144- @Optional ( ) private _dir : Directionality ) {
148+ @Optional ( ) private _dir : Directionality ,
149+ platform : Platform ) {
145150 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+ }
146158 }
147159
148160 ngAfterContentChecked ( ) : void {
@@ -208,6 +220,11 @@ export class MdTabHeader extends _MdTabHeaderMixinBase
208220 this . _realignInkBar . unsubscribe ( ) ;
209221 this . _realignInkBar = null ;
210222 }
223+
224+ if ( this . _resizeSubscription ) {
225+ this . _resizeSubscription . unsubscribe ( ) ;
226+ this . _resizeSubscription = null ;
227+ }
211228 }
212229
213230 /**
0 commit comments