88
99import { Directive , ElementRef , Inject , InjectionToken , NgZone } from '@angular/core' ;
1010
11+
1112/**
1213 * Interface for a a MatInkBar positioner method, defining the positioning and width of the ink
1314 * bar in a set of tabs.
1415 */
1516// tslint:disable-next-line class-name Using leading underscore to denote internal interface.
1617export interface _MatInkBarPositioner {
17- ( element : HTMLElement ) : { left : number , width : number } ;
18+ ( element : HTMLElement ) : { left : string , width : string } ;
1819}
1920
2021/** Injection token for the MatInkBar's Positioner. */
@@ -30,8 +31,8 @@ export const _MAT_INK_BAR_POSITIONER =
3031 */
3132export function _MAT_INK_BAR_POSITIONER_FACTORY ( ) : _MatInkBarPositioner {
3233 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' ,
3536 } ) ;
3637
3738 return method ;
@@ -45,15 +46,11 @@ export function _MAT_INK_BAR_POSITIONER_FACTORY(): _MatInkBarPositioner {
4546 selector : 'mat-ink-bar' ,
4647 host : {
4748 'class' : 'mat-ink-bar' ,
48- '[class.mat-ink-bar-animations-enabled]' : 'shouldAnimate' ,
4949 } ,
5050} )
5151export class MatInkBar {
52- /** Whether the ink bar should animate to its position. */
53- shouldAnimate = false ;
54-
5552 constructor (
56- private _elementRef : ElementRef < HTMLElement > ,
53+ private _elementRef : ElementRef ,
5754 private _ngZone : NgZone ,
5855 @Inject ( _MAT_INK_BAR_POSITIONER ) private _inkBarPositioner : _MatInkBarPositioner ) { }
5956
@@ -90,9 +87,9 @@ export class MatInkBar {
9087 */
9188 private _setStyles ( element : HTMLElement ) {
9289 const positions = this . _inkBarPositioner ( element ) ;
93- const inkBar = this . _elementRef . nativeElement ;
90+ const inkBar : HTMLElement = this . _elementRef . nativeElement ;
9491
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 ;
9794 }
9895}
0 commit comments