Slider: fix drag bug

pull/1486/head
kingwl 2016-11-30 16:58:53 +08:00 committed by 杨奕
parent c80db9ca8a
commit 932d6bdb6f
1 changed files with 18 additions and 14 deletions

View File

@ -136,7 +136,12 @@
}, },
setPosition(newPos) { setPosition(newPos) {
if (newPos >= 0 && (newPos <= 100)) { if (newPos < 0) {
newPos = 0;
} else if (newPos > 100) {
newPos = 100;
}
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);
let value = steps * lengthPerStep * (this.max - this.min) * 0.01 + this.min; let value = steps * lengthPerStep * (this.max - this.min) * 0.01 + this.min;
@ -151,7 +156,6 @@
this.oldValue = this.value; this.oldValue = this.value;
} }
} }
}
}, },
onSliderClick(event) { onSliderClick(event) {