Skip to content

Commit 98f01b5

Browse files
baikhoandreruffert
authored andcommitted
fix: html5 compliant step rounding to use min as step base
1 parent 8343801 commit 98f01b5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/range-slider-element.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,9 @@ export class RangeSliderElement extends HTMLElement {
373373
const safeValue = Math.min(Math.max(value, thumbMinValue), thumbMaxValue);
374374

375375
// Rounding in steps
376-
const nearestValue = Math.round(safeValue / this.step) * this.step;
376+
const offset = safeValue - this.min;
377+
const nearestOffset = Math.round(offset / this.step) * this.step;
378+
const nearestValue = this.min + nearestOffset;
377379

378380
// Value precision
379381
const newValue = Number(

0 commit comments

Comments
 (0)