Skip to content

Commit a1db3f3

Browse files
main - 3314414 fix(material/slider): Tick marks changes position as the slider is changed (for a step that is decimal number) (#29108)
1 parent e2185c5 commit a1db3f3

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

esm2022/slider/slider.mjs

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

fesm2022/slider.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -870,8 +870,8 @@ class MatSlider {
870870
}
871871
_updateTickMarkUINonRange(step) {
872872
const value = this._getValue();
873-
let numActive = Math.max(Math.floor((value - this.min) / step), 0);
874-
let numInactive = Math.max(Math.floor((this.max - value) / step), 0);
873+
let numActive = Math.max(Math.round((value - this.min) / step), 0);
874+
let numInactive = Math.max(Math.round((this.max - value) / step), 0);
875875
this._isRtl ? numActive++ : numInactive++;
876876
this._tickMarks = Array(numActive)
877877
.fill(_MatTickMark.ACTIVE)
@@ -880,9 +880,9 @@ class MatSlider {
880880
_updateTickMarkUIRange(step) {
881881
const endValue = this._getValue();
882882
const startValue = this._getValue(_MatThumb.START);
883-
const numInactiveBeforeStartThumb = Math.max(Math.floor((startValue - this.min) / step), 0);
884-
const numActive = Math.max(Math.floor((endValue - startValue) / step) + 1, 0);
885-
const numInactiveAfterEndThumb = Math.max(Math.floor((this.max - endValue) / step), 0);
883+
const numInactiveBeforeStartThumb = Math.max(Math.round((startValue - this.min) / step), 0);
884+
const numActive = Math.max(Math.round((endValue - startValue) / step) + 1, 0);
885+
const numInactiveAfterEndThumb = Math.max(Math.round((this.max - endValue) / step), 0);
886886
this._tickMarks = Array(numInactiveBeforeStartThumb)
887887
.fill(_MatTickMark.INACTIVE)
888888
.concat(Array(numActive).fill(_MatTickMark.ACTIVE), Array(numInactiveAfterEndThumb).fill(_MatTickMark.INACTIVE));

fesm2022/slider.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)