MCPcopy Index your code
hub / github.com/web-animations/web-animations-js / parseTransform

Function parseTransform

src/transform-handler.js:59–104  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

57 };
58
59 function parseTransform(string) {
60 string = string.toLowerCase().trim();
61 if (string == 'none')
62 return [];
63 // FIXME: Using a RegExp means calcs won't work here
64 var transformRegExp = /\s*(\w+)\(([^)]*)\)/g;
65 var result = [];
66 var match;
67 var prevLastIndex = 0;
68 while (match = transformRegExp.exec(string)) {
69 if (match.index != prevLastIndex)
70 return;
71 prevLastIndex = match.index + match[0].length;
72 var functionName = match[1];
73 var functionData = transformFunctions[functionName];
74 if (!functionData)
75 return;
76 var args = match[2].split(',');
77 var argTypes = functionData[0];
78 if (argTypes.length < args.length)
79 return;
80
81 var parsedArgs = [];
82 for (var i = 0; i < argTypes.length; i++) {
83 var arg = args[i];
84 var type = argTypes[i];
85 var parsedArg;
86 if (!arg)
87 parsedArg = ({a: Odeg,
88 n: parsedArgs[0],
89 t: Opx})[type];
90 else
91 parsedArg = ({A: function(s) { return s.trim() == '0' ? Odeg : scope.parseAngle(s); },
92 N: scope.parseNumber,
93 T: scope.parseLengthOrPercent,
94 L: scope.parseLength})[type.toUpperCase()](arg);
95 if (parsedArg === undefined)
96 return;
97 parsedArgs.push(parsedArg);
98 }
99 result.push({t: functionName, d: parsedArgs});
100
101 if (transformRegExp.lastIndex == string.length)
102 return result;
103 }
104 };
105
106 function numberToLongString(x) {
107 return x.toFixed(6).replace('.000000', '');

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…