MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / insertKeyframesProp

Function insertKeyframesProp

packages/parsers/src/gsapParser.ts:2526–2539  ·  view source on GitHub ↗

Build and prepend a keyframes property node onto varsArg.

(
  varsArg: AstNode,
  fromProps: Record<string, number | string>,
  toProps: Record<string, number | string>,
  easeEach?: string,
)

Source from the content-addressed store, hash-verified

2524
2525/** Build and prepend a keyframes property node onto varsArg. */
2526function insertKeyframesProp(
2527 varsArg: AstNode,
2528 fromProps: Record<string, number | string>,
2529 toProps: Record<string, number | string>,
2530 easeEach?: string,
2531): void {
2532 const fromEntries = Object.entries(fromProps).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);
2533 const toEntries = Object.entries(toProps).map(([k, v]) => `${safeKey(k)}: ${valueToCode(v)}`);
2534 const easeEntry = easeEach ? `, easeEach: ${JSON.stringify(easeEach)}` : "";
2535 const kfCode = `{ "0%": { ${fromEntries.join(", ")} }, "100%": { ${toEntries.join(", ")} }${easeEntry} }`;
2536 const kfProp = parseExpr(`{ keyframes: {} }`).properties[0];
2537 kfProp.value = parseExpr(kfCode);
2538 if (varsArg?.type === "ObjectExpression") varsArg.properties.unshift(kfProp);
2539}
2540
2541/**
2542 * Convert a flat tween (to/from/fromTo) to percentage-keyframes format.

Callers 1

Calls 4

safeKeyFunction · 0.85
valueToCodeFunction · 0.85
parseExprFunction · 0.85
entriesMethod · 0.80

Tested by

no test coverage detected