Skip to content

Commit

Permalink
Fixed the immediate value's calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
devedbox committed Apr 5, 2017
1 parent c8ac841 commit d5cb8e4
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ - (id)immediateValueAtTime:(CFTimeInterval)time {
#endif
@implementation CAKeyframeAnimation (ImmediateValue)
- (id)immediateValueAtTime:(CFTimeInterval)time {
if (time >= self.duration) return self.values.lastObject;

NSUInteger allFramesCount = self.values.count;
CGFloat pt = time/self.duration;

NSUInteger index = ceil(pt * allFramesCount);
if (index > self.values.count-1) return nil;
if (index > self.values.count-1) return self.values.lastObject;

id value = self.values[index];
return value;
Expand Down

0 comments on commit d5cb8e4

Please # to comment.