ReactiveCocoaLayout icon indicating copy to clipboard operation
ReactiveCocoaLayout copied to clipboard

Support key frame animations

Open joshaber opened this issue 11 years ago • 5 comments

It'd be nice if there were first-class support for key frame animations. I'm not totally sure what that would look like. Maybe an operator like -sequenceNext: but that completes when the animation completes? It'd be kinda dumb-guy keyframing but it'd work.

joshaber avatar Apr 11 '13 00:04 joshaber

Can you do this with -doAnimationCompleted:?

jspahrsummers avatar Apr 11 '13 00:04 jspahrsummers

Not really. There's no good way to run a CAKeyframeAnimation manually with the animator proxy. For the dumb-guy version, the block would need to return a new signal to use to set the keypath.

joshaber avatar Apr 11 '13 01:04 joshaber

In other words, something like:

RAC(self.view.rcl_frame) = [[[RACSignal return:frame1] animateWithDuration:0.3] animateNext:^{
    return [[RACSignal return:frame2] animateWithDuration:0.6];
}];

Where -animateNext: only continues to its block after the other animation has completed.

joshaber avatar Apr 11 '13 01:04 joshaber

Maybe this should involve a tuple representation:

RACSignal *frames = [RACSignal return:RACTuplePack(frame1, frame2)];
RAC(self.view.rcl_frame) = [frames animateKeyframesWithDurations:@[ @0.3, @0.6 ]];

The API is a bit more unwieldy (at least in terms of composability), but it's translatable to a single CAKeyframeAnimation, so there are no timing issues with paused or delayed run loops.

jspahrsummers avatar Apr 11 '13 15:04 jspahrsummers

Ehh, that API's fairly gross but I don't have any better suggestions :\

joshaber avatar Apr 12 '13 01:04 joshaber