Skip to content
Closed
2 changes: 2 additions & 0 deletions Libraries/LayoutAnimation/LayoutAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const Types = keyMirror(TypesEnum);

const PropertiesEnum = {
opacity: true,
scaleX: true,
scaleY: true,
scaleXY: true,
};
const Properties = keyMirror(PropertiesEnum);
Expand Down
14 changes: 13 additions & 1 deletion React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,10 @@ - (RCTViewManagerUIBlock)uiBlockWithLayoutUpdateForRootView:(RCTRootShadowView *
NSString *property = creatingLayoutAnimation.property;
if ([property isEqualToString:@"scaleXY"]) {
view.layer.transform = CATransform3DMakeScale(0, 0, 0);
} else if ([property isEqualToString:@"scaleX"]) {
view.layer.transform = CATransform3DMakeScale(0, 1, 0);
} else if ([property isEqualToString:@"scaleY"]) {
view.layer.transform = CATransform3DMakeScale(1, 0, 0);
} else if ([property isEqualToString:@"opacity"]) {
view.layer.opacity = 0.0;
} else {
Expand All @@ -603,7 +607,11 @@ - (RCTViewManagerUIBlock)uiBlockWithLayoutUpdateForRootView:(RCTRootShadowView *
}

[creatingLayoutAnimation performAnimations:^{
if ([property isEqualToString:@"scaleXY"]) {
if (
[property isEqualToString:@"scaleX"] ||
[property isEqualToString:@"scaleY"] ||
[property isEqualToString:@"scaleXY"]
) {
view.layer.transform = finalTransform;
} else if ([property isEqualToString:@"opacity"]) {
view.layer.opacity = finalOpacity;
Expand Down Expand Up @@ -738,6 +746,10 @@ - (void)_removeChildren:(NSArray<UIView *> *)children
[deletingLayoutAnimation performAnimations:^{
if ([property isEqualToString:@"scaleXY"]) {
removedChild.layer.transform = CATransform3DMakeScale(0.001, 0.001, 0.001);
} else if ([property isEqualToString:@"scaleX"]) {
removedChild.layer.transform = CATransform3DMakeScale(0.001, 1, 0.001);
} else if ([property isEqualToString:@"scaleY"]) {
removedChild.layer.transform = CATransform3DMakeScale(1, 0.001, 0.001);
} else if ([property isEqualToString:@"opacity"]) {
removedChild.layer.opacity = 0.0;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
/* package */ enum AnimatedPropertyType {
OPACITY("opacity"),
SCALE_X("scaleX"),
SCALE_Y("scaleY"),
SCALE_XY("scaleXY");

private final String mName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,32 @@ Animation createAnimationImpl(View view, int x, int y, int width, int height) {
Animation.RELATIVE_TO_SELF,
.5f);
}
case SCALE_X: {
float fromValue = isReverse() ? 1.0f : 0.0f;
float toValue = isReverse() ? 0.0f : 1.0f;
return new ScaleAnimation(
fromValue,
toValue,
1f,
1f,
Animation.RELATIVE_TO_SELF,
.5f,
Animation.RELATIVE_TO_SELF,
0f);
}
case SCALE_Y: {
float fromValue = isReverse() ? 1.0f : 0.0f;
float toValue = isReverse() ? 0.0f : 1.0f;
return new ScaleAnimation(
1f,
1f,
fromValue,
toValue,
Animation.RELATIVE_TO_SELF,
0f,
Animation.RELATIVE_TO_SELF,
.5f);
}
default:
throw new IllegalViewOperationException(
"Missing animation for property : " + mAnimatedProperty);
Expand Down