fix(circle): Fix the bug of shake when the circle component value is a decimal number. (#4152)

* fix(circle): Fix the bug of shake when the circle component value is a decimal number

* fix(circle): Fix the bug of shake when the circle component value is a decimal number
This commit is contained in:
YotrolZ 2021-05-18 18:15:14 +08:00 committed by GitHub
parent 9d1c8b2ca9
commit a641b0922d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -185,11 +185,15 @@ VantComponent({
this.currentValue = this.currentValue || 0; this.currentValue = this.currentValue || 0;
this.interval = setInterval(() => { this.interval = setInterval(() => {
if (this.currentValue !== value) { if (this.currentValue !== value) {
if (Math.abs(this.currentValue - value) < STEP) {
this.currentValue = value;
} else {
if (this.currentValue < value) { if (this.currentValue < value) {
this.currentValue += STEP; this.currentValue += STEP;
} else { } else {
this.currentValue -= STEP; this.currentValue -= STEP;
} }
}
this.drawCircle(this.currentValue); this.drawCircle(this.currentValue);
} else { } else {
this.clearInterval(); this.clearInterval();