(text: string)
| 66 | }); |
| 67 | |
| 68 | export function transformConverter(text: string): TransformFunctionsInfo { |
| 69 | const transformations = parseTransformString(text); |
| 70 | |
| 71 | if (text === 'none' || text === '' || !transformations.length) { |
| 72 | return IDENTITY_TRANSFORMATION; |
| 73 | } |
| 74 | |
| 75 | const usedTransforms = transformations.map((t) => t.property); |
| 76 | if (!hasDuplicates(usedTransforms)) { |
| 77 | const fullTransformations = { ...IDENTITY_TRANSFORMATION }; |
| 78 | transformations.forEach((transform) => { |
| 79 | fullTransformations[transform.property] = transform.value; |
| 80 | }); |
| 81 | |
| 82 | return fullTransformations; |
| 83 | } |
| 84 | |
| 85 | const affineMatrix = transformations.map(getTransformMatrix).reduce(multiplyAffine2d); |
| 86 | const cssMatrix = matrixArrayToCssMatrix(affineMatrix); |
| 87 | |
| 88 | return decompose2DTransformMatrix(cssMatrix); |
| 89 | } |
| 90 | |
| 91 | function isTransformType(propertyName: string): propertyName is TransformationType { |
| 92 | return (TRANSFORMATIONS as string[]).indexOf(propertyName) !== -1; |
no test coverage detected