Skip to content

Commit 4a2c15c

Browse files
committed
fix(tabs): Set initial ink bar width as 0 width
1 parent fd23c02 commit 4a2c15c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/lib/tabs/_tabs-common.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ $mat-tab-animation-duration: 500ms !default;
5454
bottom: 0;
5555
height: $height;
5656
width: 1px;
57+
transform: translateX(0px) scaleX(0);
5758
transform-origin: 0;
5859

5960
.mat-tab-group-inverted-header & {

src/lib/tabs/ink-bar.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ export function _MAT_INK_BAR_POSITIONER_FACTORY(): _MatInkBarPositioner {
4545
selector: 'mat-ink-bar',
4646
host: {
4747
'class': 'mat-ink-bar',
48+
'[class.mat-ink-bar-animations-enabled]': 'shouldAnimate',
4849
},
4950
})
5051
export class MatInkBar {
52+
/** Whether the ink bar should animate to its position. */
53+
shouldAnimate = false;
54+
5155
constructor(
5256
private _elementRef: ElementRef<HTMLElement>,
5357
private _ngZone: NgZone,
@@ -88,12 +92,7 @@ export class MatInkBar {
8892
const positions = this._inkBarPositioner(element);
8993
const inkBar = this._elementRef.nativeElement;
9094

91-
// We want to prevent the ink bar from animating on the initial load.
92-
// Enable animations only if the ink bar has been translated before.
93-
if (inkBar.style.transform) {
94-
inkBar.classList.add('mat-ink-bar-animations-enabled');
95-
}
96-
9795
inkBar.style.transform = `translateX(${positions.left}px) scaleX(${positions.width})`;
96+
this.shouldAnimate = true;
9897
}
9998
}

0 commit comments

Comments
 (0)