From 548549ea9fdd1c2e7d4135069bbb0096240be2aa Mon Sep 17 00:00:00 2001 From: chirag04 Date: Tue, 14 Jul 2015 19:41:07 -0700 Subject: [PATCH] [style] expose rotate x, y, z transforms Summary: Added rotateX, rotateY, rotateZ transforms. cc @sahrens Closes https://github.com/facebook/react-native/pull/1976 Github Author: chirag04 --- Libraries/StyleSheet/TransformPropTypes.js | 4 ++++ Libraries/StyleSheet/precomputeStyle.js | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/Libraries/StyleSheet/TransformPropTypes.js b/Libraries/StyleSheet/TransformPropTypes.js index c9f403f75..06728d0b7 100644 --- a/Libraries/StyleSheet/TransformPropTypes.js +++ b/Libraries/StyleSheet/TransformPropTypes.js @@ -17,6 +17,10 @@ var TransformPropTypes = { transform: ReactPropTypes.arrayOf( ReactPropTypes.oneOfType([ ReactPropTypes.shape({rotate: ReactPropTypes.string}), + ReactPropTypes.shape({rotateX: ReactPropTypes.string}), + ReactPropTypes.shape({rotateY: ReactPropTypes.string}), + ReactPropTypes.shape({rotateZ: ReactPropTypes.string}), + ReactPropTypes.shape({scale: ReactPropTypes.number}), ReactPropTypes.shape({scaleX: ReactPropTypes.number}), ReactPropTypes.shape({scaleY: ReactPropTypes.number}), ReactPropTypes.shape({translateX: ReactPropTypes.number}), diff --git a/Libraries/StyleSheet/precomputeStyle.js b/Libraries/StyleSheet/precomputeStyle.js index 3294494fa..0e166e1c4 100644 --- a/Libraries/StyleSheet/precomputeStyle.js +++ b/Libraries/StyleSheet/precomputeStyle.js @@ -58,7 +58,14 @@ function _precomputeTransforms(style: Object): Object { case 'matrix': MatrixMath.multiplyInto(result, result, value); break; + case 'rotateX': + _multiplyTransform(result, MatrixMath.reuseRotateXCommand, [_convertToRadians(value)]); + break; + case 'rotateY': + _multiplyTransform(result, MatrixMath.reuseRotateYCommand, [_convertToRadians(value)]); + break; case 'rotate': + case 'rotateZ': _multiplyTransform(result, MatrixMath.reuseRotateZCommand, [_convertToRadians(value)]); break; case 'scale': @@ -156,6 +163,9 @@ function _validateTransform(key, value, transformation) { break; case 'translate': break; + case 'rotateX': + case 'rotateY': + case 'rotateZ': case 'rotate': invariant( typeof value === 'string',