Skip to content

Commit 40f4c66

Browse files
genkikondofacebook-github-bot
authored andcommitted
Set correct initial value for AnimatedComponent for styles backed by native animated nodes
Summary: In AnimatedComponent.render, we get the initial values of any styles backed by AnimatedNode, but ONLY for non-native animations. Thus, if convert an animated node to native before the call to render to mount the component, we will end up not applying the initial value until after the component is mounted. This may result in a visible flicker as the expected value is applied some time after the component is mounted and visible. - Without native driver: BaseViewManager.setTransform called during view preallocation (ViewManager.createViewInstance) - With native driver: BaseViewManager.setTransform called during MountingManager.updateProps (called from PropsAnimatedNode.updateView) This diff removes the isNative check in AnimatedStyle and AnimatedProps when traversing style props. This shouldn't be a problem: - Created as non-native, animated with JS driver - This diff does not affect this scenario - Created as non-native, animated with native driver - Initial value is applied correctly on render/mount. On subsequent renders, the outdated value from JS side will not apply on the platform view as it has not changed. - Created as native, animated with native driver - Initial value is applied correctly on render/mount. On subsequent renders, the outdated value from JS side will not apply on the platform view as it has not changed. Changelog: [Internal][Fixed] - Set correct initial value for AnimatedComponent for styles backed by native animated nodes Reviewed By: JoshuaGross, javache Differential Revision: D36612758 fbshipit-source-id: 922d6534c605b3eb0a1d9476753111b726f138f2
1 parent ba6bf5a commit 40f4c66

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

Libraries/Animated/nodes/AnimatedProps.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ class AnimatedProps extends AnimatedNode {
4141
for (const key in this._props) {
4242
const value = this._props[key];
4343
if (value instanceof AnimatedNode) {
44-
if (!value.__isNative || value instanceof AnimatedStyle) {
45-
// We cannot use value of natively driven nodes this way as the value we have access from
46-
// JS may not be up to date.
47-
props[key] = value.__getValue();
48-
}
44+
props[key] = value.__getValue();
4945
} else if (value instanceof AnimatedEvent) {
5046
props[key] = value.__getHandler();
5147
} else {

Libraries/Animated/nodes/AnimatedStyle.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ class AnimatedStyle extends AnimatedWithChildren {
3939
for (const key in style) {
4040
const value = style[key];
4141
if (value instanceof AnimatedNode) {
42-
if (!value.__isNative) {
43-
// We cannot use value of natively driven nodes this way as the value we have access from
44-
// JS may not be up to date.
45-
updatedStyle[key] = value.__getValue();
46-
}
42+
updatedStyle[key] = value.__getValue();
4743
} else if (value && !Array.isArray(value) && typeof value === 'object') {
4844
// Support animating nested values (for example: shadowOffset.height)
4945
updatedStyle[key] = this._walkStyleAndGetValues(value);

0 commit comments

Comments
 (0)