mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-08 17:15:04 +00:00
[web] Fix rotation transform handling, and simplify style resolution
This commit is contained in:
+9
-12
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user