-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Introducing Keyframe-like animation definition schema #2195
Conversation
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.
Solid PR 🚀
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.
It isn't part of the 2.3.0-alpha.1 release so adding docs to that may be unnecessary.
After consultation with @piaskowyk we've changed the approach a little bit. When a property is missing from the keyframe, instead of copying its value from the previous keyframe, we decided to increase the duration of the animation to the value in the next keyframe. So in such case: const animation = new Keyframe({
from: {
originX: 50,
transform: [{ rotate: '45deg' }],
},
30: {
transform: [{ rotate: '-90deg' }],
},
100: {
originX: 0,
transform: [{ rotate: '0deg' }],
easing: Easing.quad,
},
}); Animation to \cc @jakub-gonet |
This looks like a better approach. If I understand it correctly, do you try to "fill the gaps" between two occurrences of the given property and interpolate it between two points? What happens if we have code like this? const animation = new Keyframe({
0: {
originX: 50, // <- this property is being interpolated
transform: [{ rotate: '45deg' }],
easing: Easing.linear,
},
30: {
transform: [{ rotate: '-90deg' }],
easing: Easing.bezier,
},
100: {
originX: 0,
transform: [{ rotate: '0deg' }],
easing: Easing.quad,
},
}); that is if we have different easings between those points? Do every property follows the same easing and On a side note, I'm not sure about mixing |
Yes, exactly.
No, currently property follows only this easing which is defined in the same point. So, because
@piaskowyk what do you think? |
New edge case: const animation = new Keyframe({
from: {
transform: [{rotate: '45deg'}, {scaleX: 1}, {rotate: '0deg'}],
},
to: {
transform: [{rotate: '-90deg'}, {scaleX: 0.2}, {rotate: '80deg'}],
}
}); |
Description
To simplify the way how complex animations are defined, this PR introduces a keyframe like animation definition schema. It is inspired by the animation definition schema used in CSS and react-native-animatable. In the result user will be able to define animation using Keyframe:
After creating Keyframe object the user can pass it as a prop to
Animated.View
component (i.ex. as entering animation).Changes
Screenshots / GIFs
keyframeAnimation.mov
Test code and steps to reproduce
Checklist