[web] Fix rotation transform handling, and simplify style resolution

This commit is contained in:
Mikael Sand
2019-03-10 01:39:05 +02:00
parent 53e91fcdfc
commit 70c5954285
+9 -12
View File
@@ -4,11 +4,10 @@ function resolve(styleProp, cleanedProps) {
if (styleProp) { if (styleProp) {
return StyleSheet return StyleSheet
? [styleProp, cleanedProps] ? [styleProp, cleanedProps]
: { : // Compatibility for arrays of styles in plain react web
// Compatibility for arrays of styles in plain react web styleProp.length
...(styleProp.length ? Object.assign({}, ...styleProp) : styleProp), ? Object.assign({}, ...styleProp, cleanedProps)
...cleanedProps, : Object.assign({}, styleProp, cleanedProps);
};
} else { } else {
return cleanedProps; return cleanedProps;
} }
@@ -27,7 +26,7 @@ function prepare(props) {
const { const {
translate, translate,
scale, scale,
rotate, rotation,
skewX, skewX,
skewY, skewY,
originX, originX,
@@ -55,8 +54,9 @@ function prepare(props) {
if (scale != null) { if (scale != null) {
transform.push(`scale(${scale})`); transform.push(`scale(${scale})`);
} }
if (rotate != null) { // rotation maps to rotate, not to collide with the text rotate attribute
transform.push(`rotate(${rotate})`); if (rotation != null) {
transform.push(`rotate(${rotation})`);
} }
if (skewX != null) { if (skewX != null) {
transform.push(`skewX(${skewX})`); transform.push(`skewX(${skewX})`);
@@ -86,10 +86,7 @@ function prepare(props) {
styles.fontStyle = fontStyle; styles.fontStyle = fontStyle;
} }
/* eslint-enable eqeqeq */ /* eslint-enable eqeqeq */
clean.style = resolve( clean.style = resolve(style, styles);
style,
styles,
);
return clean; return clean;
} }