From a5c2966051635e0e9bf3a8e1806bec962116534f Mon Sep 17 00:00:00 2001 From: Miles Steele Date: Wed, 6 Jan 2016 17:28:35 -0500 Subject: [PATCH 1/2] draw nothing when progress is 0 --- ProgressCircle.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ProgressCircle.js b/ProgressCircle.js index f8e9a21..f4e850e 100644 --- a/ProgressCircle.js +++ b/ProgressCircle.js @@ -95,7 +95,7 @@ return this; }, - + /** * @method Manually update all circles */ @@ -227,6 +227,11 @@ * @returns this */ _draw: function() { + if (this.progress == 0) { + // Draw nothing when progress is 0. + return + } + var ctx = this.context, ANGLE_OFFSET = -Math.PI / 2, From 6561871d01c3fdd13cf5ce815d19a5e8e3f57264 Mon Sep 17 00:00:00 2001 From: Miles Steele Date: Wed, 6 Jan 2016 21:17:40 -0500 Subject: [PATCH 2/2] add fillColorComplete --- ProgressCircle.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ProgressCircle.js b/ProgressCircle.js index f4e850e..bc9a487 100644 --- a/ProgressCircle.js +++ b/ProgressCircle.js @@ -53,6 +53,7 @@ /** * @method Adds an progress monitor entry. * @param params.fillColor Color to fill in the circle. + * @param params.fillColorComplete Color to fill in the circle when complete. * @param params.outlineColor Color to outline the circle. * @param params.progressListener Callback function to fetch the progress. * @param params.infoListener Callback function to fetch the info. @@ -72,6 +73,7 @@ id: this.circles.length, fillColor: params.fillColor, + fillColorComplete: params.fillColorComplete, outlineColor: params.outlineColor, progressListener: params.progressListener, infoListener: params.infoListener, @@ -149,6 +151,7 @@ * @param params.centerX X coordinate of the center of circles. * @param params.centerY Y coordinate of the center of circles. * @param params.fillColor Color to fill in the circle. + * @param params.fillColor Color to fill in the circle when complete. * @param params.outlineColor Color to outline the circle. * @param params.progressListener Callback function to fetch the progress. * @param params.infoListener Callback function to fetch the info. @@ -163,6 +166,7 @@ this.arcWidth = params.arcWidth; this.innerRadius = params.innerRadius || 0; this.fillColor = params.fillColor || '#fff'; + this.fillColorComplete = params.fillColorComplete || this.fillColor; this.outlineColor = params.outlineColor || this.fillColor; this.progressListener = params.progressListener; this.infoLineLength = params.infoLineLength || 250; @@ -245,8 +249,13 @@ innerRadius = this.innerRadius, outerRadius = this.outerRadius; - ctx.fillStyle = this.fillColor; - ctx.strokeStyle = this.outlineColor; + if (this.progress == 1) { + ctx.fillStyle = this.fillColorComplete; + ctx.strokeStyle = this.fillColorComplete; + } else { + ctx.fillStyle = this.fillColor; + ctx.strokeStyle = this.outlineColor; + } ctx.beginPath(); ctx.arc(x, y, innerRadius, startAngle, endAngle, false);