We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5f2aa85 commit f3ce9c1Copy full SHA for f3ce9c1
src/range_slider.js
@@ -403,9 +403,11 @@ export default class extends Controller {
403
if (!this.activePointer) return;
404
405
let coordX = e.touches ? e.touches[0].pageX : e.pageX;
406
- let index = coordX - this.sliderLeft - this.pointerWidth / 2;
+ let relativePosition = coordX - this.sliderLeft;
407
+ let percentage = relativePosition / this.sliderWidth;
408
+ let index = Math.round(percentage * (this.values.range.length - 1));
409
- index = Math.round(index / this.stepWidth);
410
+ // Ensure index is within valid range
411
index = Math.max(0, Math.min(index, this.values.range.length - 1));
412
413
if (this.isRange) {
0 commit comments