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.
This commit is contained in:
parent
9f249603d0
commit
2e3a7bf557
1 changed files with 3 additions and 2 deletions
|
@ -372,9 +372,10 @@
|
|||
const currentX = this.getPointerX(event);
|
||||
const sliderOffsetLeft = this.$refs.slider.getBoundingClientRect().left;
|
||||
let newPos = ((currentX - sliderOffsetLeft) / this.sliderWidth * this.valueRange) + this.min;
|
||||
let regularNewPos = newPos / this.valueRange * 100 ;
|
||||
|
||||
if (!this.range || newPos <= this.minPosition) this.changeButtonPosition(newPos, 'min');
|
||||
else if (newPos >= this.maxPosition) this.changeButtonPosition(newPos, 'max');
|
||||
if (!this.range || regularNewPos <= this.minPosition) this.changeButtonPosition(newPos, 'min');
|
||||
else if (regularNewPos >= this.maxPosition) this.changeButtonPosition(newPos, 'max');
|
||||
else this.changeButtonPosition(newPos, ((newPos - this.firstPosition) <= (this.secondPosition - newPos)) ? 'min' : 'max');
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue