Created
December 20, 2013 01:38
-
-
Save mallorypaine/8049184 to your computer and use it in GitHub Desktop.
IFTTAnimation accumulates errors in a subtle way. Every time you add an animation, the timeline gets one extra entry. Here's my fix. Note that the inner for-loop used to break when j <= nextKeyFrameTime. Suppose you have keyFrames at times 100, 200, and 300. With <= nextKeyFrameTime, you'll get two entries for time 100, 200, and 300, and you'll …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.timeline = [NSMutableArray new]; | |
for (NSUInteger i = 0; i < self.keyFrames.count - 1; i++) { | |
IFTTTAnimationKeyFrame *keyFrame = [self.keyFrames objectAtIndex:i]; | |
IFTTTAnimationKeyFrame *nextKeyFrame = [self.keyFrames objectAtIndex:i+1]; | |
NSInteger j; | |
for (j = keyFrame.time; j < nextKeyFrame.time; j++) { | |
[self.timeline addObject:[self frameForTime:j startKeyFrame:keyFrame endKeyFrame:nextKeyFrame]]; | |
} | |
if (i + 1 == self.keyFrames.count - 1) { | |
[self.timeline addObject:[self frameForTime:j startKeyFrame:keyFrame endKeyFrame:nextKeyFrame]]; | |
} | |
} | |
self.startTime = ((IFTTTAnimationKeyFrame *)[self.keyFrames objectAtIndex:0]).time; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment