fix(styling): change transform parameters parsing (#9481)

Fixed the incorrectly applied short form of "transform: translate" style property.

closes #5202
This commit is contained in:
Sergey Mell
2021-08-11 20:45:00 +03:00
committed by Nathan Walker
parent 37c0731a8a
commit 2a4563716a
2 changed files with 8 additions and 2 deletions

View File

@ -212,7 +212,7 @@ export function test_ReadTranslateSingle() {
TKUnit.assertEqual(translate.property, 'translate');
TKUnit.assertAreClose(translate.value.x, 30, DELTA);
TKUnit.assertAreClose(translate.value.y, 30, DELTA);
TKUnit.assertAreClose(translate.value.y, 0, DELTA);
}
export function test_ReadTranslateXY() {

View File

@ -736,7 +736,13 @@ function normalizeTransformation({ property, value }: Transformation): Transform
}
function convertTransformValue(property: string, stringValue: string): TransformationValue {
const [x, y = x, z = y] = stringValue.split(',').map(parseFloat);
let [x, y, z] = stringValue.split(',').map(parseFloat);
if (property === 'translate') {
y ??= IDENTITY_TRANSFORMATION.translate.y;
} else {
y ??= x;
z ??= y;
}
if (property === 'rotate' || property === 'rotateX' || property === 'rotateY') {
return stringValue.slice(-3) === 'rad' ? radiansToDegrees(x) : x;