diff --git a/React/Views/RCTConvert+Transform.m b/React/Views/RCTConvert+Transform.m index 94e5dcd6cd91c4..06a0db3b4863e3 100644 --- a/React/Views/RCTConvert+Transform.m +++ b/React/Views/RCTConvert+Transform.m @@ -65,6 +65,7 @@ + (CATransform3D)CATransform3D:(id)json CGFloat zeroScaleThreshold = FLT_EPSILON; + CATransform3D next; for (NSDictionary *transformConfig in (NSArray *)json) { if (transformConfig.count != 1) { RCTLogConvertError(json, @"a CATransform3D. You must specify exactly one property per transform object."); @@ -74,10 +75,13 @@ + (CATransform3D)CATransform3D:(id)json id value = transformConfig[property]; if ([property isEqualToString:@"matrix"]) { - transform = [self CATransform3DFromMatrix:value]; + next = [self CATransform3DFromMatrix:value]; + transform = CATransform3DConcat(next, transform); } else if ([property isEqualToString:@"perspective"]) { - transform.m34 = -1 / [value floatValue]; + next = CATransform3DIdentity; + next.m34 = -1 / [value floatValue]; + transform = CATransform3DConcat(next, transform); } else if ([property isEqualToString:@"rotateX"]) { CGFloat rotate = [self convertToRadians:value]; @@ -123,11 +127,15 @@ + (CATransform3D)CATransform3D:(id)json } else if ([property isEqualToString:@"skewX"]) { CGFloat skew = [self convertToRadians:value]; - transform.m21 = tanf(skew); + next = CATransform3DIdentity; + next.m21 = tanf(skew); + transform = CATransform3DConcat(next, transform); } else if ([property isEqualToString:@"skewY"]) { CGFloat skew = [self convertToRadians:value]; - transform.m12 = tanf(skew); + next = CATransform3DIdentity; + next.m12 = tanf(skew); + transform = CATransform3DConcat(next, transform); } else { RCTLogError(@"Unsupported transform type for a CATransform3D: %@.", property);