[Doc] Circle: update demo

This commit is contained in:
陈嘉涵
2019-07-06 11:42:49 +08:00
parent 8f0644e3ec
commit 22c1b14bc2
5 changed files with 27 additions and 18 deletions
+3
View File
@@ -56,6 +56,7 @@ export default createComponent({
layerStyle() {
let offset = (PERIMETER * (100 - this.value)) / 100;
offset = this.clockwise ? offset : PERIMETER * 2 - offset;
return {
stroke: `${this.color}`,
strokeDashoffset: `${offset}px`,
@@ -80,6 +81,7 @@ export default createComponent({
this.endRate = format(this.rate);
this.increase = this.endRate > this.startRate;
this.duration = Math.abs(((this.startRate - this.endRate) * 1000) / this.speed);
if (this.speed) {
cancelRaf(this.rafId);
this.rafId = raf(this.animate);
@@ -97,6 +99,7 @@ export default createComponent({
const progress = Math.min((now - this.startTime) / this.duration, 1);
const rate = progress * (this.endRate - this.startRate) + this.startRate;
this.$emit('input', format(parseFloat(rate.toFixed(1))));
if (this.increase ? rate < this.endRate : rate > this.endRate) {
this.rafId = raf(this.animate);
}