Permalink
Browse files

Fixed previously broken support for negative `scale` (`transform` sty…

…le property)

Summary:
closes #13081

UIExplorer, TransformExample
Closes #13083

Reviewed By: mmmulani

Differential Revision: D4758237

Pulled By: shergin

fbshipit-source-id: 58385a4cde7a739b6657c293c381644a92918265
  • Loading branch information...
skv-headless authored and facebook-github-bot committed Mar 25, 2017
1 parent 09fe999 commit c87c4d052f9a450c37ef94875fed170d0a58dc50
Showing with 9 additions and 3 deletions.
  1. +9 −3 React/Views/RCTConvert+Transform.m
@@ -63,6 +63,9 @@ + (CATransform3D)CATransform3D:(id)json
RCTLogWarn(@"[RCTConvert CATransform3D:] has deprecated a matrix as input. Pass an array of configs (which can contain a matrix key) instead.");
return [self CATransform3DFromMatrix:json];
}
CGFloat zeroScaleThreshold = FLT_EPSILON;
for (NSDictionary *transformConfig in (NSArray<NSDictionary *> *)json) {
if (transformConfig.count != 1) {
RCTLogConvertError(json, @"a CATransform3D. You must specify exactly one property per transform object.");
@@ -90,15 +93,18 @@ + (CATransform3D)CATransform3D:(id)json
transform = CATransform3DRotate(transform, rotate, 0, 0, 1);
} else if ([property isEqualToString:@"scale"]) {
CGFloat scale = MAX([value floatValue], FLT_EPSILON);
CGFloat scale = [value floatValue];
scale = ABS(scale) < zeroScaleThreshold ? zeroScaleThreshold : scale;
transform = CATransform3DScale(transform, scale, scale, 1);
} else if ([property isEqualToString:@"scaleX"]) {
CGFloat scale = MAX([value floatValue], FLT_EPSILON);
CGFloat scale = [value floatValue];
scale = ABS(scale) < zeroScaleThreshold ? zeroScaleThreshold : scale;
transform = CATransform3DScale(transform, scale, 1, 1);
} else if ([property isEqualToString:@"scaleY"]) {
CGFloat scale = MAX([value floatValue], FLT_EPSILON);
CGFloat scale = [value floatValue];
scale = ABS(scale) < zeroScaleThreshold ? zeroScaleThreshold : scale;
transform = CATransform3DScale(transform, 1, scale, 1);
} else if ([property isEqualToString:@"translate"]) {

0 comments on commit c87c4d0

Please sign in to comment.