Fix translate shorthand and add array support

https://github.com/react-native-community/react-native-svg/issues/998
This commit is contained in:
Mikael Sand
2019-04-19 04:48:45 +03:00
committed by GitHub
parent 276a6e93af
commit 0835b50056
+9 -2
View File
@@ -30,6 +30,13 @@ function universal2axis(universal, axisX, axisY, defaultValue) {
} else if (coords.length === 1) {
x = y = +coords[0];
}
} else if (Array.isArray(universal)) {
if (universal.length === 2) {
x = +universal[0];
y = +universal[1];
} else if (universal.length === 1) {
x = y = +universal[0];
}
}
axisX = +axisX;
@@ -51,8 +58,8 @@ export function props2transform(props) {
const skew = universal2axis(props.skew, props.skewX, props.skewY);
const translate = universal2axis(
props.translate,
props.translateX == null ? props.x || 0 : props.translateX,
props.translateY == null ? props.y || 0 : props.translateY,
props.translateX || props.x,
props.translateY || props.y,
);
return {