Skip to content

Commit

Permalink
Fabric: Implementation of <View transform={...}/> property
Browse files Browse the repository at this point in the history
Summary: After moving all matrix math to C++, the actual client native code is quite trivial.

Reviewed By: fkgozali

Differential Revision: D8344059

fbshipit-source-id: 6910c6af5de64d5f901e82075d30edbde177af40
  • Loading branch information
shergin authored and facebook-github-bot committed Jun 15, 2018
1 parent 55f8cfe commit dc0ebf7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ - (void)updateProps:(SharedProps)props
self.userInteractionEnabled = newViewProps.pointerEvents != PointerEventsMode::None;
}

// `transform`
if (oldViewProps.transform != newViewProps.transform) {
self.layer.transform = RCTCATransform3DFromTransformMatrix(newViewProps.transform);
self.layer.allowsEdgeAntialiasing = newViewProps.transform != Transform::Identity();
}

// TODO: Implement all sutable non-layout <View> props.
Expand Down
22 changes: 22 additions & 0 deletions React/Fabric/RCTConversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,28 @@ inline UIEdgeInsets RCTUIEdgeInsetsFromEdgeInsets(facebook::react::EdgeInsets ed
return {edgeInsets.top, edgeInsets.left, edgeInsets.bottom, edgeInsets.right};
}


inline CATransform3D RCTCATransform3DFromTransformMatrix(facebook::react::Transform transformMatrix) {
return {
(CGFloat)transformMatrix.matrix[0],
(CGFloat)transformMatrix.matrix[1],
(CGFloat)transformMatrix.matrix[2],
(CGFloat)transformMatrix.matrix[3],
(CGFloat)transformMatrix.matrix[4],
(CGFloat)transformMatrix.matrix[5],
(CGFloat)transformMatrix.matrix[6],
(CGFloat)transformMatrix.matrix[7],
(CGFloat)transformMatrix.matrix[8],
(CGFloat)transformMatrix.matrix[9],
(CGFloat)transformMatrix.matrix[10],
(CGFloat)transformMatrix.matrix[11],
(CGFloat)transformMatrix.matrix[12],
(CGFloat)transformMatrix.matrix[13],
(CGFloat)transformMatrix.matrix[14],
(CGFloat)transformMatrix.matrix[15]
};
}

inline facebook::react::Point RCTPointFromCGPoint(CGPoint point) {
return {point.x, point.y};
}
Expand Down

0 comments on commit dc0ebf7

Please sign in to comment.