Skip to content

Commit d5cb8e4

Browse files
committed
Fixed the immediate value's calculation.
1 parent c8ac841 commit d5cb8e4

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

AXAnimationChain/Classes/CoreAnimation/CAAnimation+ImmediateValue.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@ - (id)immediateValueAtTime:(CFTimeInterval)time {
8484
#endif
8585
@implementation CAKeyframeAnimation (ImmediateValue)
8686
- (id)immediateValueAtTime:(CFTimeInterval)time {
87+
if (time >= self.duration) return self.values.lastObject;
88+
8789
NSUInteger allFramesCount = self.values.count;
8890
CGFloat pt = time/self.duration;
8991

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

9395
id value = self.values[index];
9496
return value;

0 commit comments

Comments
 (0)