facebookarchive / Keyframes

A library for converting Adobe AE shape based animations to a data format and playing it back on Android and iOS devices.
https://facebookincubator.github.io/Keyframes/
Other
5.33k stars 302 forks source link

Implement delegates / listener to track playback #96

Closed hansemannn closed 4 years ago

hansemannn commented 7 years ago

Not 100 % sure if that's available already, but we should create a delegate (iOS) / listener (Android) to notify the developer who implements the delegate / listener about the current progress. Is there an interest on this functionality? Then I'd implement it. 🚀

lozzle commented 7 years ago

We have some callbacks for animation end that we can probably flesh out into a full listener. If there's a use case for tighter callbacks, I don't see why we'd be opposed to adding it in- go ahead!

tureki commented 7 years ago

+1 This was very useful 👍

hansemannn commented 7 years ago

Thanks! I have something working, but will require a bit more resources to test it properly. Current delegates:

- (void)vectorLayer:(KFVectorLayer *)vectorLayer didStartAnimation:(CAAnimation *)animation;

- (void)vectorLayer:(KFVectorLayer *)vectorLayer didStopAnimation:(CAAnimation *)animation;

- (void)vectorLayer:(KFVectorLayer *)vectorLayer didResumeAnimation:(CAAnimation *)animation;

We might want to add some userInfo there as well, so the developer can identify the animation more easy.

subtleGradient commented 7 years ago

I don't want to call something on every frame if avoidable. I've been thinking about integrating Adobe After Effects markers into callbacks. That way you'll get a call back with the name of the current marker whenever that changes. That could let you trigger specific interactivity like looping or randomizing animation segments without having to manually keep track of frame numbers manually

hansemannn commented 7 years ago

@subtleGradient 100 % agree. We need a real world use-case before exposing something from the scratch. The markers make sense, maybe some additional states as well. Please feel free to do it instead of you feel you have an idea that needs to leave your head 🤓