From 2e3a7bf557e421513f12dcbec98aa5e0c7582a38 Mon Sep 17 00:00:00 2001 From: Haven Date: Wed, 27 Jun 2018 16:30:11 +0800 Subject: [PATCH] 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. --- src/components/slider/slider.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/slider/slider.vue b/src/components/slider/slider.vue index 9fc13214..ec4e14c0 100644 --- a/src/components/slider/slider.vue +++ b/src/components/slider/slider.vue @@ -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'); },