@@ -26,11 +26,23 @@ import {ViewportRuler} from '../../core/overlay/position/viewport-ruler';
26
26
encapsulation : ViewEncapsulation . None ,
27
27
} )
28
28
export class MdTabNavBar {
29
+ _activeLinkChanged : boolean ;
30
+ _activeLinkElement : ElementRef ;
31
+
29
32
@ViewChild ( MdInkBar ) _inkBar : MdInkBar ;
30
33
31
- /** Animates the ink bar to the position of the active link element. */
32
- updateActiveLink ( element : HTMLElement ) {
33
- this . _inkBar . alignToElement ( element ) ;
34
+ /** Notifies the component that the active link has been changed. */
35
+ updateActiveLink ( element : ElementRef ) {
36
+ this . _activeLinkChanged = this . _activeLinkElement != element ;
37
+ this . _activeLinkElement = element ;
38
+ }
39
+
40
+ /** Checks if the active link has been changed and, if so, will update the ink bar. */
41
+ ngAfterContentChecked ( ) : void {
42
+ if ( this . _activeLinkChanged ) {
43
+ this . _inkBar . alignToElement ( this . _activeLinkElement . nativeElement ) ;
44
+ this . _activeLinkChanged = false ;
45
+ }
34
46
}
35
47
}
36
48
@@ -39,6 +51,9 @@ export class MdTabNavBar {
39
51
*/
40
52
@Directive ( {
41
53
selector : '[md-tab-link], [mat-tab-link]' ,
54
+ host : {
55
+ '[class.mat-tab-link]' : 'true' ,
56
+ }
42
57
} )
43
58
export class MdTabLink {
44
59
private _isActive : boolean = false ;
@@ -49,11 +64,11 @@ export class MdTabLink {
49
64
set active ( value : boolean ) {
50
65
this . _isActive = value ;
51
66
if ( value ) {
52
- this . _mdTabNavBar . updateActiveLink ( this . _element . nativeElement ) ;
67
+ this . _mdTabNavBar . updateActiveLink ( this . _elementRef ) ;
53
68
}
54
69
}
55
70
56
- constructor ( private _mdTabNavBar : MdTabNavBar , private _element : ElementRef ) { }
71
+ constructor ( private _mdTabNavBar : MdTabNavBar , private _elementRef : ElementRef ) { }
57
72
}
58
73
59
74
/**
0 commit comments