MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / transformConverter

Function transformConverter

packages/core/ui/styling/css-transform.ts:68–89  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

66});
67
68export 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
91function isTransformType(propertyName: string): propertyName is TransformationType {
92 return (TRANSFORMATIONS as string[]).indexOf(propertyName) !== -1;

Callers 2

convertToTransformFunction · 0.90

Calls 7

hasDuplicatesFunction · 0.90
matrixArrayToCssMatrixFunction · 0.90
parseTransformStringFunction · 0.85
forEachMethod · 0.80
reduceMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected