Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(material/slider): use flex to position tick marks #30299

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/material/slider/slider-thumb.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,3 @@
height: 100%;
width: 100%;
}

.mat-mdc-slider .mdc-slider__tick-marks {
justify-content: start;
.mdc-slider__tick-mark--active,
.mdc-slider__tick-mark--inactive {
position: absolute;
left: 2px;
}
}
4 changes: 1 addition & 3 deletions src/material/slider/slider.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
<div class="mdc-slider__tick-marks" #tickMarkContainer>
@if (_cachedWidth) {
@for (tickMark of _tickMarks; track i; let i = $index) {
<div
[class]="tickMark === 0 ? 'mdc-slider__tick-mark--active' : 'mdc-slider__tick-mark--inactive'"
[style.transform]="_calcTickMarkTransform(i)"></div>
<div [class]="tickMark === 0 ? 'mdc-slider__tick-mark--active' : 'mdc-slider__tick-mark--inactive'"></div>
}
}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/material/slider/slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ $_mat-slots: (tokens-mat-slider.$prefix, tokens-mat-slider.get-token-slots());
display: flex;
height: 100%;
justify-content: space-between;
padding: 0 1px;
padding: 0 2px;
position: absolute;
width: 100%;
}
Expand Down
7 changes: 0 additions & 7 deletions src/material/slider/slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,13 +587,6 @@ export class MatSlider implements AfterViewInit, OnDestroy, _MatSlider {
trackStyle.transform = styles.transform;
}

/** Returns the translateX positioning for a tick mark based on it's index. */
_calcTickMarkTransform(index: number): string {
// TODO(wagnermaciel): See if we can avoid doing this and just using flex to position these.
const translateX = index * (this._tickMarkTrackWidth / (this._tickMarks.length - 1));
return `translateX(${translateX}px`;
}

// Handlers for updating the slider ui.

_onTranslateXChange(source: _MatSliderThumb): void {
Expand Down
1 change: 0 additions & 1 deletion tools/public_api_guard/material/slider.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export class MatSlider implements AfterViewInit, OnDestroy, _MatSlider {
_cachedLeft: number;
// (undocumented)
_cachedWidth: number;
_calcTickMarkTransform(index: number): string;
// (undocumented)
readonly _cdr: ChangeDetectorRef;
color: ThemePalette;
Expand Down
Loading