slider组件 step为小数时回不到100的bug
This commit is contained in:
parent
3b71312aac
commit
cd07742407
1 changed files with 6 additions and 4 deletions
|
@ -327,7 +327,7 @@
|
||||||
if (type === 'min') newPos = this.checkLimits([newPos, this.maxPosition])[0];
|
if (type === 'min') newPos = this.checkLimits([newPos, this.maxPosition])[0];
|
||||||
else newPos = this.checkLimits([this.minPosition, newPos])[1];
|
else newPos = this.checkLimits([this.minPosition, newPos])[1];
|
||||||
|
|
||||||
const modulus = this.handleDecimal(newPos,this.step)
|
const modulus = this.handleDecimal(newPos,this.step);
|
||||||
const value = this.currentValue;
|
const value = this.currentValue;
|
||||||
value[index] = newPos - modulus;
|
value[index] = newPos - modulus;
|
||||||
this.currentValue = [...value];
|
this.currentValue = [...value];
|
||||||
|
@ -342,10 +342,12 @@
|
||||||
if(step<1){
|
if(step<1){
|
||||||
let sl = step.toString(),
|
let sl = step.toString(),
|
||||||
multiple = 1,
|
multiple = 1,
|
||||||
m = 0;
|
m;
|
||||||
try {
|
try {
|
||||||
m += sl.split('.')[1].length;
|
m = sl.split('.')[1].length;
|
||||||
} catch (e) {}
|
} catch (e){
|
||||||
|
m = 0;
|
||||||
|
}
|
||||||
multiple = Math.pow(10,m);
|
multiple = Math.pow(10,m);
|
||||||
return (pos * multiple) % (step * multiple) / multiple;
|
return (pos * multiple) % (step * multiple) / multiple;
|
||||||
}else return pos % step;
|
}else return pos % step;
|
||||||
|
|
Loading…
Add table
Reference in a new issue