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

Function tweenCallToAnimation

packages/parsers/src/gsapParser.ts:919–1046  ·  view source on GitHub ↗
(
  call: TweenCallInfo,
  scope: ScopeBindings,
)

Source from the content-addressed store, hash-verified

917
918// fallow-ignore-next-line complexity
919function tweenCallToAnimation(
920 call: TweenCallInfo,
921 scope: ScopeBindings,
922): Omit<GsapAnimation, "id"> {
923 const vars = objectExpressionToRecord(call.varsArg, scope);
924 const properties: Record<string, number | string> = {};
925 const extras: Record<string, unknown> = {};
926 let keyframesData: GsapKeyframesData | undefined;
927 let hasUnresolvedKeyframes = false;
928 let motionPathResult: MotionPathParseResult | undefined;
929
930 for (const [key, val] of Object.entries(vars)) {
931 if (BUILTIN_VAR_KEYS.has(key)) continue;
932 if (DROPPED_VAR_KEYS.has(key)) continue;
933
934 if (key === "keyframes") {
935 const kfNode = findPropertyNode(call.varsArg, "keyframes");
936 keyframesData = parseKeyframesNode(kfNode, scope);
937 if (!keyframesData && kfNode) hasUnresolvedKeyframes = true;
938 continue;
939 }
940
941 if (key === "motionPath") {
942 const mpNode = findPropertyNode(call.varsArg, "motionPath");
943 motionPathResult = parseMotionPathNode(mpNode, scope);
944 continue;
945 }
946
947 if (key === "easeEach") {
948 // easeEach is only meaningful alongside keyframes — handled below.
949 continue;
950 }
951
952 if (EXTRAS_KEYS.has(key)) {
953 // For extras, prefer the raw AST source so complex objects like
954 // `stagger: { each: 0.15, from: "start" }` survive verbatim.
955 const rawSource = extractRawPropertySource(call.varsArg, key);
956 if (rawSource !== undefined) {
957 extras[key] = `__raw:${rawSource}`;
958 } else if (val !== undefined) {
959 extras[key] = val;
960 }
961 continue;
962 }
963
964 if (typeof val === "number" || typeof val === "string") {
965 properties[key] = val;
966 }
967 }
968
969 // Apply tween-level easeEach to keyframes data.
970 if (keyframesData && typeof vars.easeEach === "string") {
971 keyframesData.easeEach = vars.easeEach as string;
972 }
973
974 // When motionPath is present, reconstruct x/y as keyframe waypoints.
975 if (motionPathResult) {
976 const { waypoints } = motionPathResult;

Callers 1

parseGsapAstFunction · 0.70

Calls 9

entriesMethod · 0.80
objectExpressionToRecordFunction · 0.70
findPropertyNodeFunction · 0.70
parseKeyframesNodeFunction · 0.70
parseMotionPathNodeFunction · 0.70
extractRawPropertySourceFunction · 0.70
extractLiteralValueFunction · 0.70

Tested by

no test coverage detected