File tree 3 files changed +35
-1
lines changed
packages/react-native-web/src
3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -188,6 +188,28 @@ describe('StyleSheet/preprocess', () => {
188
188
} ) ;
189
189
} ) ;
190
190
} ) ;
191
+
192
+ describe ( 'transformOrigin' , ( ) => {
193
+ // passthrough if transformOrigin value is ever a string
194
+ test ( 'string' , ( ) => {
195
+ const transformOrigin = '2px 30% 10px' ;
196
+ const style = { transformOrigin } ;
197
+ const resolved = preprocess ( style ) ;
198
+
199
+ expect ( resolved ) . toEqual ( { transformOrigin } ) ;
200
+ } ) ;
201
+
202
+ test ( 'array' , ( ) => {
203
+ const style = {
204
+ transformOrigin : [ 2 , '30%' , 10 ]
205
+ } ;
206
+ const resolved = preprocess ( style ) ;
207
+
208
+ expect ( resolved ) . toEqual ( {
209
+ transformOrigin : '2px 30% 10px'
210
+ } ) ;
211
+ } ) ;
212
+ } ) ;
191
213
} ) ;
192
214
193
215
describe ( 'preprocesses multiple shadow styles into a single declaration' , ( ) => {
Original file line number Diff line number Diff line change @@ -92,6 +92,13 @@ export const createTransformValue = (value: Array<Object>): string => {
92
92
return value . map ( mapTransform ) . join ( ' ' ) ;
93
93
} ;
94
94
95
+ // [2, '30%', 10] => '2px 30% 10px'
96
+ export const createTransformOriginValue = (
97
+ value : Array < number | string >
98
+ ) : string => {
99
+ return value . map ( ( v ) => normalizeValueWithProperty ( v ) ) . join ( ' ' ) ;
100
+ } ;
101
+
95
102
const PROPERTIES_STANDARD : { [ key : string ] : string } = {
96
103
borderBottomEndRadius : 'borderEndEndRadius' ,
97
104
borderBottomStartRadius : 'borderEndStartRadius' ,
@@ -231,6 +238,11 @@ export const preprocess = <T: {| [key: string]: any |}>(
231
238
value = createTransformValue ( value ) ;
232
239
}
233
240
nextStyle . transform = value ;
241
+ } else if ( prop === 'transformOrigin' ) {
242
+ if ( Array . isArray ( value ) ) {
243
+ value = createTransformOriginValue ( value ) ;
244
+ }
245
+ nextStyle . transformOrigin = value ;
234
246
} else {
235
247
nextStyle [ prop ] = value ;
236
248
}
Original file line number Diff line number Diff line change @@ -341,6 +341,6 @@ export type TransformStyles = {|
341
341
| { | + translateZ : NumberOrString | }
342
342
| { | + translate3d : string | }
343
343
> ,
344
- transformOrigin ?: ?string ,
344
+ transformOrigin ?: ?string | Array < NumberOrString > ,
345
345
transformStyle ?: ?( 'flat' | 'preserve-3d' )
346
346
| } ;
You can’t perform that action at this time.
0 commit comments