Commit a3da61b7651180d2b6192a88cd6d1ba85163f390

Authored by Aresn
Committed by GitHub
2 parents a1a1e0c7 cd077424

Merge pull request #3288 from yangbean4/2.0

fix #3195
Showing 1 changed file with 16 additions and 4 deletions   Show diff stats
src/components/slider/slider.vue
@@ -326,12 +326,11 @@ @@ -326,12 +326,11 @@
326 const index = type === 'min' ? 0 : 1; 326 const index = type === 'min' ? 0 : 1;
327 if (type === 'min') newPos = this.checkLimits([newPos, this.maxPosition])[0]; 327 if (type === 'min') newPos = this.checkLimits([newPos, this.maxPosition])[0];
328 else newPos = this.checkLimits([this.minPosition, newPos])[1]; 328 else newPos = this.checkLimits([this.minPosition, newPos])[1];
329 -  
330 - const modulus = newPos % this.step; 329 +
  330 + const modulus = this.handleDecimal(newPos,this.step);
331 const value = this.currentValue; 331 const value = this.currentValue;
332 value[index] = newPos - modulus; 332 value[index] = newPos - modulus;
333 this.currentValue = [...value]; 333 this.currentValue = [...value];
334 -  
335 if (!this.dragging) { 334 if (!this.dragging) {
336 if (this.currentValue[index] !== this.oldValue[index]) { 335 if (this.currentValue[index] !== this.oldValue[index]) {
337 this.emitChange(); 336 this.emitChange();
@@ -339,7 +338,20 @@ @@ -339,7 +338,20 @@
339 } 338 }
340 } 339 }
341 }, 340 },
342 - 341 + handleDecimal(pos,step){
  342 + if(step<1){
  343 + let sl = step.toString(),
  344 + multiple = 1,
  345 + m;
  346 + try {
  347 + m = sl.split('.')[1].length;
  348 + } catch (e){
  349 + m = 0;
  350 + }
  351 + multiple = Math.pow(10,m);
  352 + return (pos * multiple) % (step * multiple) / multiple;
  353 + }else return pos % step;
  354 + },
343 emitChange(){ 355 emitChange(){
344 const value = this.range ? this.exportValue : this.exportValue[0]; 356 const value = this.range ? this.exportValue : this.exportValue[0];
345 this.$emit('on-change', value); 357 this.$emit('on-change', value);