@@ -21,6 +21,7 @@ import {
21
21
AfterContentInit ,
22
22
OnDestroy ,
23
23
NgZone ,
24
+ Renderer2 ,
24
25
} from '@angular/core' ;
25
26
import {
26
27
RIGHT_ARROW ,
@@ -136,6 +137,7 @@ export class MdTabHeader implements AfterContentChecked, AfterContentInit, OnDes
136
137
constructor (
137
138
private _elementRef : ElementRef ,
138
139
private _ngZone : NgZone ,
140
+ private _renderer : Renderer2 ,
139
141
@Optional ( ) private _dir : Directionality ) { }
140
142
141
143
ngAfterContentChecked ( ) : void {
@@ -299,12 +301,11 @@ export class MdTabHeader implements AfterContentChecked, AfterContentInit, OnDes
299
301
300
302
/** Performs the CSS transformation on the tab list that will cause the list to scroll. */
301
303
_updateTabScrollPosition ( ) {
302
- let translateX = this . scrollDistance + 'px' ;
303
- if ( this . _getLayoutDirection ( ) == 'ltr' ) {
304
- translateX = '-' + translateX ;
305
- }
304
+ const scrollDistance = this . scrollDistance ;
305
+ const translateX = this . _getLayoutDirection ( ) === 'ltr' ? - scrollDistance : scrollDistance ;
306
306
307
- applyCssTransform ( this . _tabList . nativeElement , `translate3d(${ translateX } , 0, 0)` ) ;
307
+ this . _renderer . setStyle ( this . _tabList . nativeElement , 'transform' ,
308
+ `translate3d(${ translateX } px, 0, 0)` ) ;
308
309
}
309
310
310
311
/** Sets the distance in pixels that the tab header should be transformed in the X-axis. */
@@ -317,7 +318,7 @@ export class MdTabHeader implements AfterContentChecked, AfterContentInit, OnDes
317
318
318
319
this . _checkScrollingControls ( ) ;
319
320
}
320
- get scrollDistance ( ) : number { return this . _scrollDistance ; }
321
+ get scrollDistance ( ) : number { return this . _scrollDistance ; }
321
322
322
323
/**
323
324
* Moves the tab list in the 'before' or 'after' direction (towards the beginning of the list or
@@ -413,7 +414,7 @@ export class MdTabHeader implements AfterContentChecked, AfterContentInit, OnDes
413
414
_getMaxScrollDistance ( ) : number {
414
415
const lengthOfTabList = this . _tabList . nativeElement . scrollWidth ;
415
416
const viewLength = this . _tabListContainer . nativeElement . offsetWidth ;
416
- return lengthOfTabList - viewLength ;
417
+ return ( lengthOfTabList - viewLength ) || 0 ;
417
418
}
418
419
419
420
/** Tells the ink-bar to align itself to the current label wrapper */
0 commit comments