-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support animating multiple properties of shape bezier paths #1690
Conversation
Sources/Private/CoreAnimation/Animations/RectangleAnimation.swift
Outdated
Show resolved
Hide resolved
value: { position in | ||
// We can only use one set of keyframes to animate a given CALayer keypath, | ||
// so we currently animate `position` and ignore any other keyframes. | ||
// TODO: Is there a way to support this properly? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO: Is there a way to support this properly?
Good news, yes! 😝
108d9a8
to
11b73a8
Compare
11b73a8
to
ba14b04
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just one question about whether we can make it safer using generics
let combinedKeyframes = Keyframes.combinedIfPossible(size, position) { untypedValues in | ||
Keyframe( | ||
size: untypedValues[0] as! Vector3D, | ||
position: untypedValues[1] as! Vector3D) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused what's going on here, why are we force casting these to Vector3D
if both params are of type Vector3D
? Is this due to limitations around variadic parameters and generics? Wondering if we could instead just make multiple arities of this function with tuples, similar to how Combine works with operators, since this feels a bit brittle/unsafe as-is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you answered this before I submitted the review, feel free to merge as-is if you'd like 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having multiple arities is an interesting idea, I'll try it out and see how it goes. It would definitely be easier to understand the callsite without this casting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion, this worked out nicely: 96980ab
This case is now just:
let combinedKeyframes = Keyframes.combinedIfPossible(
size, position,
makeCombinedResult: Ellipse.Keyframe.init)
d58ff0c
to
26d7fa8
Compare
I noticed the animations added in #1688 were marked as unsupported by the Core Animation rendering engine, even though they rendered correctly.
This PR updates the Core Animation rendering engine to support animating multiple properties of shape bezier paths. Now those animations are fully supported by the new engine.
To render shapes, we basically have to combine multiple
KeyframeGroup<Vector3D>
/KeyframeGroup<Vector1D>
s into a singleKeyframeGroup<BezierPath>
. Originally we implemented this by just taking the keyframe timing information from one component and discarding the rest. Instead we can useKeyframes.combinedIfPossible
to merge together all of the keyframes groups if they have the same timing information.