update Slider

This commit is contained in:
梁灏 2017-04-07 09:38:55 +08:00
parent bb1a3c38b4
commit 2f8104a321

View file

@ -360,7 +360,11 @@
} }
}, },
changeFirstPosition (newPos) { changeFirstPosition (newPos) {
if (newPos >= 0 && (newPos <= this.secondPosition)) { if (newPos < 0) {
newPos = 0;
} else if (newPos > this.secondPosition) {
newPos = this.secondPosition;
}
const lengthPerStep = 100 / ((this.max - this.min) / this.step); const lengthPerStep = 100 / ((this.max - this.min) / this.step);
const steps = Math.round(newPos / lengthPerStep); const steps = Math.round(newPos / lengthPerStep);
@ -373,7 +377,6 @@
this.oldFirstValue = this.currentValue[0]; this.oldFirstValue = this.currentValue[0];
} }
} }
}
}, },
setFirstPosition (val) { setFirstPosition (val) {
this.firstPosition = (val - this.min) / (this.max - this.min) * 100; this.firstPosition = (val - this.min) / (this.max - this.min) * 100;
@ -410,7 +413,11 @@
} }
}, },
changeSecondPosition (newPos) { changeSecondPosition (newPos) {
if (newPos >= this.firstPosition && (newPos <= 100)) { if (newPos > 100) {
newPos = 100;
} else if (newPos < this.firstPosition) {
newPos = this.firstPosition;
}
const lengthPerStep = 100 / ((this.max - this.min) / this.step); const lengthPerStep = 100 / ((this.max - this.min) / this.step);
const steps = Math.round(newPos / lengthPerStep); const steps = Math.round(newPos / lengthPerStep);
@ -423,7 +430,6 @@
this.oldSecondValue = this.currentValue[1]; this.oldSecondValue = this.currentValue[1];
} }
} }
}
}, },
setSecondPosition (val) { setSecondPosition (val) {
this.secondPosition = (val - this.min) / (this.max - this.min) * 100; this.secondPosition = (val - this.min) / (this.max - this.min) * 100;