Emma Makinson

Remove update animation on PNCircleChart

@@ -209,24 +209,35 @@ displayCountingLabel:(BOOL)displayCountingLabel @@ -209,24 +209,35 @@ displayCountingLabel:(BOOL)displayCountingLabel
209 } 209 }
210 210
211 -(void)updateChartByCurrent:(NSNumber *)current byTotal:(NSNumber *)total { 211 -(void)updateChartByCurrent:(NSNumber *)current byTotal:(NSNumber *)total {
212 - // Add animation 212 + double totalPercentageValue = [current floatValue]/([total floatValue]/100.0);
213 - CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];  
214 - pathAnimation.duration = self.duration;  
215 - pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];  
216 - pathAnimation.fromValue = @([_current floatValue] / [_total floatValue]);  
217 - pathAnimation.toValue = @([current floatValue] / [total floatValue]);  
218 - _circle.strokeEnd = [current floatValue] / [total floatValue];  
219 213
220 if (_strokeColorGradientStart) { 214 if (_strokeColorGradientStart) {
221 self.gradientMask.strokeEnd = _circle.strokeEnd; 215 self.gradientMask.strokeEnd = _circle.strokeEnd;
222 - [self.gradientMask addAnimation:pathAnimation forKey:@"strokeEndAnimation"];  
223 } 216 }
224 - [_circle addAnimation:pathAnimation forKey:@"strokeEndAnimation"];  
225 217
226 - if (_displayCountingLabel) { 218 + // Add animation
227 - [self.countingLabel countFrom:fmin([_current floatValue], [_total floatValue]) to:[current floatValue]/([total floatValue]/100.0) withDuration:self.duration]; 219 + if (self.displayAnimated) {
  220 + CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
  221 + pathAnimation.duration = self.duration;
  222 + pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
  223 + pathAnimation.fromValue = @([_current floatValue] / [_total floatValue]);
  224 + pathAnimation.toValue = @([current floatValue] / [total floatValue]);
  225 +
  226 + if (_strokeColorGradientStart) {
  227 + [self.gradientMask addAnimation:pathAnimation forKey:@"strokeEndAnimation"];
  228 + }
  229 + [_circle addAnimation:pathAnimation forKey:@"strokeEndAnimation"];
  230 +
  231 + if (_displayCountingLabel) {
  232 + [self.countingLabel countFrom:fmin([_current floatValue], [_total floatValue]) to:totalPercentageValue withDuration:self.duration];
  233 + }
  234 +
  235 + }
  236 + else if (_displayCountingLabel) {
  237 + [self.countingLabel countFrom:totalPercentageValue to:totalPercentageValue withDuration:self.duration];
228 } 238 }
229 239
  240 + _circle.strokeEnd = [current floatValue] / [total floatValue];
230 _current = current; 241 _current = current;
231 _total = total; 242 _total = total;
232 } 243 }