-
-
Notifications
You must be signed in to change notification settings - Fork 696
Expand file tree
/
Copy pathwrapStyleTransforms.js
More file actions
33 lines (32 loc) · 713 Bytes
/
wrapStyleTransforms.js
File metadata and controls
33 lines (32 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// These styles need to be nested in a transform array
const TRANSFORM_STYLE_PROPERTIES = [
'perspective',
'rotate',
'rotateX',
'rotateY',
'rotateZ',
'scale',
'scaleX',
'scaleY',
'skewX',
'skewY',
'translateX',
'translateY',
];
// Transforms { translateX: 1 } to { transform: [{ translateX: 1 }]}
export default function wrapStyleTransforms(style) {
const wrapped = {};
Object.keys(style).forEach((key) => {
if (TRANSFORM_STYLE_PROPERTIES.indexOf(key) !== -1) {
if (!wrapped.transform) {
wrapped.transform = [];
}
wrapped.transform.push({
[key]: style[key],
});
} else {
wrapped[key] = style[key];
}
});
return wrapped;
}