Skip to content

Commit

Permalink
fix(material/slider): fix track getting out of sync (#27218)
Browse files Browse the repository at this point in the history
* fix(material/slider): fix track getting out of sync

* fixup! fix(material/slider): fix track getting out of sync

* fixup! fix(material/slider): fix track getting out of sync
  • Loading branch information
wagnermaciel authored Jun 2, 2023
1 parent 88d3906 commit 7108734
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
12 changes: 0 additions & 12 deletions src/material/slider/slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ $mat-slider-horizontal-margin: 8px !default;
.mdc-slider__track--active_fill {
transition-duration: 80ms;
}

&.mat-mdc-slider-disable-track-animation {
.mdc-slider__track--active_fill {
transition-duration: 0ms;
}
}
}

// We need to repeat these styles to override discrete slider styling.
Expand All @@ -78,12 +72,6 @@ $mat-slider-horizontal-margin: 8px !default;
.mdc-slider__track--active_fill {
transition-duration: 80ms;
}

&.mat-mdc-slider-disable-track-animation {
.mdc-slider__track--active_fill {
transition-duration: 0ms;
}
}
}

.mdc-slider__track,
Expand Down
15 changes: 2 additions & 13 deletions src/material/slider/slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
} from '@angular/material/core';
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
import {Subscription} from 'rxjs';
import {take} from 'rxjs/operators';
import {
_MatThumb,
_MatTickMark,
Expand Down Expand Up @@ -585,22 +584,11 @@ export class MatSlider
transformOrigin: string;
}): void {
const trackStyle = this._trackActive.nativeElement.style;
const animationOriginChanged =
styles.left !== trackStyle.left && styles.right !== trackStyle.right;

trackStyle.left = styles.left;
trackStyle.right = styles.right;
trackStyle.transformOrigin = styles.transformOrigin;

if (animationOriginChanged) {
this._elementRef.nativeElement.classList.add('mat-mdc-slider-disable-track-animation');
this._ngZone.onStable.pipe(take(1)).subscribe(() => {
this._elementRef.nativeElement.classList.remove('mat-mdc-slider-disable-track-animation');
trackStyle.transform = styles.transform;
});
} else {
trackStyle.transform = styles.transform;
}
trackStyle.transform = styles.transform;
}

/** Returns the translateX positioning for a tick mark based on it's index. */
Expand Down Expand Up @@ -913,6 +901,7 @@ export class MatSlider
private _updateTickMarkUIRange(step: number): void {
const endValue = this._getValue();
const startValue = this._getValue(_MatThumb.START);

const numInactiveBeforeStartThumb = Math.max(Math.floor((startValue - this.min) / step), 0);
const numActive = Math.max(Math.floor((endValue - startValue) / step) + 1, 0);
const numInactiveAfterEndThumb = Math.max(Math.floor((this.max - endValue) / step), 0);
Expand Down

0 comments on commit 7108734

Please sign in to comment.