Commit 4a12cdd2d811124930b1be1eb875b222f764c4a1

Authored by Aresn
Committed by GitHub
2 parents 048b6af3 2e3a7bf5

Merge pull request #3968 from Baoyx007/patch-4

fix(slider): click slider bar get wrong action when max is beyond 100
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  
... ...