Skip to content

Commit

Permalink
fix(tabs): Set initial ink bar width as 0 width (#11585)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephperrott authored May 31, 2018
1 parent bb297c9 commit c977763
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/lib/tabs/_tabs-common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ $mat-tab-animation-duration: 500ms !default;
bottom: 0;
height: $height;
width: 1px;
transform: translateX(0) scaleX(0);
transform-origin: 0;

.mat-tab-group-inverted-header & {
Expand Down
11 changes: 5 additions & 6 deletions src/lib/tabs/ink-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ export function _MAT_INK_BAR_POSITIONER_FACTORY(): _MatInkBarPositioner {
selector: 'mat-ink-bar',
host: {
'class': 'mat-ink-bar',
'[class.mat-ink-bar-animations-enabled]': 'shouldAnimate',
},
})
export class MatInkBar {
/** Whether the ink bar should animate to its position. */
shouldAnimate = false;

constructor(
private _elementRef: ElementRef<HTMLElement>,
private _ngZone: NgZone,
Expand Down Expand Up @@ -88,12 +92,7 @@ export class MatInkBar {
const positions = this._inkBarPositioner(element);
const inkBar = this._elementRef.nativeElement;

// We want to prevent the ink bar from animating on the initial load.
// Enable animations only if the ink bar has been translated before.
if (inkBar.style.transform) {
inkBar.classList.add('mat-ink-bar-animations-enabled');
}

inkBar.style.transform = `translateX(${positions.left}px) scaleX(${positions.width})`;
this.shouldAnimate = true;
}
}

0 comments on commit c977763

Please sign in to comment.