Skip to content

Commit 96553cf

Browse files
Felipe Martimfacebook-github-bot-8
authored andcommitted
Add rotateX and rotateY transforms to Android Views .
Summary: Setting rotateX and rotateY for Android Views. Closes facebook#4413 Reviewed By: svcscm Differential Revision: D2741328 Pulled By: mkonicek fb-gh-sync-id: 931027c006bc571ef374a7b82cc7074b8a34bc8d
1 parent 64a78ed commit 96553cf

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Libraries/Utilities/MatrixMath.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,10 @@ var MatrixMath = {
465465

466466
// Solve the equation by inverting perspectiveMatrix and multiplying
467467
// rightHandSide by the inverse.
468-
var inversePerspectiveMatrix = MatrixMath.inverse3x3(
468+
var inversePerspectiveMatrix = MatrixMath.inverse(
469469
perspectiveMatrix
470470
);
471-
var transposedInversePerspectiveMatrix = MatrixMath.transpose4x4(
471+
var transposedInversePerspectiveMatrix = MatrixMath.transpose(
472472
inversePerspectiveMatrix
473473
);
474474
var perspective = MatrixMath.multiplyVectorByMatrix(
@@ -583,6 +583,8 @@ var MatrixMath = {
583583
translation,
584584

585585
rotate: rotationDegrees[2],
586+
rotateX: rotationDegrees[0],
587+
rotateY: rotationDegrees[1],
586588
scaleX: scale[0],
587589
scaleY: scale[1],
588590
translateX: translation[0],

ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
1818
private static final String PROP_BACKGROUND_COLOR = ViewProps.BACKGROUND_COLOR;
1919
private static final String PROP_DECOMPOSED_MATRIX = "decomposedMatrix";
2020
private static final String PROP_DECOMPOSED_MATRIX_ROTATE = "rotate";
21+
private static final String PROP_DECOMPOSED_MATRIX_ROTATE_X = "rotateX";
22+
private static final String PROP_DECOMPOSED_MATRIX_ROTATE_Y = "rotateY";
2123
private static final String PROP_DECOMPOSED_MATRIX_SCALE_X = "scaleX";
2224
private static final String PROP_DECOMPOSED_MATRIX_SCALE_Y = "scaleY";
2325
private static final String PROP_DECOMPOSED_MATRIX_TRANSLATE_X = "translateX";
@@ -144,6 +146,10 @@ private static void setTransformMatrix(View view, ReadableMap matrix) {
144146
(float) matrix.getDouble(PROP_DECOMPOSED_MATRIX_TRANSLATE_Y)));
145147
view.setRotation(
146148
(float) matrix.getDouble(PROP_DECOMPOSED_MATRIX_ROTATE));
149+
view.setRotationX(
150+
(float) matrix.getDouble(PROP_DECOMPOSED_MATRIX_ROTATE_X));
151+
view.setRotationY(
152+
(float) matrix.getDouble(PROP_DECOMPOSED_MATRIX_ROTATE_Y));
147153
view.setScaleX(
148154
(float) matrix.getDouble(PROP_DECOMPOSED_MATRIX_SCALE_X));
149155
view.setScaleY(
@@ -154,6 +160,8 @@ private static void resetTransformMatrix(View view) {
154160
view.setTranslationX(PixelUtil.toPixelFromDIP(0));
155161
view.setTranslationY(PixelUtil.toPixelFromDIP(0));
156162
view.setRotation(0);
163+
view.setRotationX(0);
164+
view.setRotationY(0);
157165
view.setScaleX(1);
158166
view.setScaleY(1);
159167
}

0 commit comments

Comments
 (0)