Commit 2e3a7bf557e421513f12dcbec98aa5e0c7582a38

Authored by Haven
Committed by GitHub
1 parent 9f249603

fix(slider): click slider bar get wrong action when max is beyond 100

the newPos compared with minPosition should be Regularized.

eg: [https://jsfiddle.net/6yhxfkn3/3/](https://jsfiddle.net/6yhxfkn3/3/) , click the left side of the min point.
Showing 1 changed file with 3 additions and 2 deletions   Show diff stats
src/components/slider/slider.vue
... ... @@ -372,9 +372,10 @@
372 372 const currentX = this.getPointerX(event);
373 373 const sliderOffsetLeft = this.$refs.slider.getBoundingClientRect().left;
374 374 let newPos = ((currentX - sliderOffsetLeft) / this.sliderWidth * this.valueRange) + this.min;
  375 + let regularNewPos = newPos / this.valueRange * 100 ;
375 376  
376   - if (!this.range || newPos <= this.minPosition) this.changeButtonPosition(newPos, 'min');
377   - else if (newPos >= this.maxPosition) this.changeButtonPosition(newPos, 'max');
  377 + if (!this.range || regularNewPos <= this.minPosition) this.changeButtonPosition(newPos, 'min');
  378 + else if (regularNewPos >= this.maxPosition) this.changeButtonPosition(newPos, 'max');
378 379 else this.changeButtonPosition(newPos, ((newPos - this.firstPosition) <= (this.secondPosition - newPos)) ? 'min' : 'max');
379 380 },
380 381  
... ...