8
8
9
9
import { Directive , ElementRef , Inject , InjectionToken , NgZone } from '@angular/core' ;
10
10
11
+
11
12
/**
12
13
* Interface for a a MatInkBar positioner method, defining the positioning and width of the ink
13
14
* bar in a set of tabs.
14
15
*/
15
16
// tslint:disable-next-line class-name Using leading underscore to denote internal interface.
16
17
export interface _MatInkBarPositioner {
17
- ( element : HTMLElement ) : { left : number , width : number } ;
18
+ ( element : HTMLElement ) : { left : string , width : string } ;
18
19
}
19
20
20
21
/** Injection token for the MatInkBar's Positioner. */
@@ -30,8 +31,8 @@ export const _MAT_INK_BAR_POSITIONER =
30
31
*/
31
32
export function _MAT_INK_BAR_POSITIONER_FACTORY ( ) : _MatInkBarPositioner {
32
33
const method = ( element : HTMLElement ) => ( {
33
- left : element ? ( element . offsetLeft || 0 ) : 0 ,
34
- width : element ? ( element . offsetWidth || 0 ) : 0 ,
34
+ left : element ? ( element . offsetLeft || 0 ) + 'px' : '0' ,
35
+ width : element ? ( element . offsetWidth || 0 ) + 'px' : '0' ,
35
36
} ) ;
36
37
37
38
return method ;
@@ -45,15 +46,11 @@ export function _MAT_INK_BAR_POSITIONER_FACTORY(): _MatInkBarPositioner {
45
46
selector : 'mat-ink-bar' ,
46
47
host : {
47
48
'class' : 'mat-ink-bar' ,
48
- '[class.mat-ink-bar-animations-enabled]' : 'shouldAnimate' ,
49
49
} ,
50
50
} )
51
51
export class MatInkBar {
52
- /** Whether the ink bar should animate to its position. */
53
- shouldAnimate = false ;
54
-
55
52
constructor (
56
- private _elementRef : ElementRef < HTMLElement > ,
53
+ private _elementRef : ElementRef ,
57
54
private _ngZone : NgZone ,
58
55
@Inject ( _MAT_INK_BAR_POSITIONER ) private _inkBarPositioner : _MatInkBarPositioner ) { }
59
56
@@ -90,9 +87,9 @@ export class MatInkBar {
90
87
*/
91
88
private _setStyles ( element : HTMLElement ) {
92
89
const positions = this . _inkBarPositioner ( element ) ;
93
- const inkBar = this . _elementRef . nativeElement ;
90
+ const inkBar : HTMLElement = this . _elementRef . nativeElement ;
94
91
95
- inkBar . style . transform = `translateX( ${ positions . left } px) scaleX( ${ positions . width } )` ;
96
- this . shouldAnimate = true ;
92
+ inkBar . style . left = positions . left ;
93
+ inkBar . style . width = positions . width ;
97
94
}
98
95
}
0 commit comments