Emma Makinson

Remove update animation on PNCircleChart

... ... @@ -209,24 +209,35 @@ displayCountingLabel:(BOOL)displayCountingLabel
}
-(void)updateChartByCurrent:(NSNumber *)current byTotal:(NSNumber *)total {
// Add animation
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = self.duration;
pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pathAnimation.fromValue = @([_current floatValue] / [_total floatValue]);
pathAnimation.toValue = @([current floatValue] / [total floatValue]);
_circle.strokeEnd = [current floatValue] / [total floatValue];
double totalPercentageValue = [current floatValue]/([total floatValue]/100.0);
if (_strokeColorGradientStart) {
self.gradientMask.strokeEnd = _circle.strokeEnd;
[self.gradientMask addAnimation:pathAnimation forKey:@"strokeEndAnimation"];
}
[_circle addAnimation:pathAnimation forKey:@"strokeEndAnimation"];
if (_displayCountingLabel) {
[self.countingLabel countFrom:fmin([_current floatValue], [_total floatValue]) to:[current floatValue]/([total floatValue]/100.0) withDuration:self.duration];
// Add animation
if (self.displayAnimated) {
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
pathAnimation.duration = self.duration;
pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
pathAnimation.fromValue = @([_current floatValue] / [_total floatValue]);
pathAnimation.toValue = @([current floatValue] / [total floatValue]);
if (_strokeColorGradientStart) {
[self.gradientMask addAnimation:pathAnimation forKey:@"strokeEndAnimation"];
}
[_circle addAnimation:pathAnimation forKey:@"strokeEndAnimation"];
if (_displayCountingLabel) {
[self.countingLabel countFrom:fmin([_current floatValue], [_total floatValue]) to:totalPercentageValue withDuration:self.duration];
}
}
else if (_displayCountingLabel) {
[self.countingLabel countFrom:totalPercentageValue to:totalPercentageValue withDuration:self.duration];
}
_circle.strokeEnd = [current floatValue] / [total floatValue];
_current = current;
_total = total;
}
... ...