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:
Haven 2018-06-27 16:30:11 +08:00 committed by GitHub
parent 9f249603d0
commit 2e3a7bf557
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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');
},