Skip to content

Commit 7652c87

Browse files
authoredJun 4, 2018
Revert "perf(tabs): use a transform to resize and move the ink bar" (#11661)
This reverts commit 63b6fd9.
1 parent b962eee commit 7652c87

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed
 

‎src/lib/tabs/_tabs-common.scss

+2-9
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,17 @@ $mat-tab-animation-duration: 500ms !default;
5050
$height: 2px;
5151

5252
position: absolute;
53-
left: 0;
5453
bottom: 0;
5554
height: $height;
56-
width: 1px;
57-
transform: translateX(0) scaleX(0);
58-
transform-origin: 0;
55+
transition: $mat-tab-animation-duration $ease-in-out-curve-function;
5956

6057
.mat-tab-group-inverted-header & {
6158
bottom: auto;
6259
top: 0;
6360
}
6461

65-
&.mat-ink-bar-animations-enabled {
66-
transition: transform $mat-tab-animation-duration $ease-in-out-curve-function;
67-
}
68-
6962
@include cdk-high-contrast {
70-
border-bottom: solid $height;
63+
outline: solid $height;
7164
height: 0;
7265
}
7366
}

‎src/lib/tabs/ink-bar.ts

+8-11
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88

99
import {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.
1617
export 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
*/
3132
export 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
})
5151
export 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

Comments
 (0)