Skip to content

Instantly share code, notes, and snippets.

View mallorypaine's full-sized avatar

Mallory Paine mallorypaine

  • Perf Nuts
  • Park City, UT
View GitHub Profile
@mallorypaine
mallorypaine / gist:8049184
Created December 20, 2013 01:38
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 …
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) {