Merge pull request #3968 from Baoyx007/patch-4

fix(slider): click slider bar get wrong action when max is beyond 100
This commit is contained in:
Aresn 2019-01-07 17:08:22 +08:00 committed by GitHub
commit 4a12cdd2d8
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');
},