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

Function resolveConversionProps

packages/parsers/src/gsapSerialize.ts:483–512  ·  view source on GitHub ↗
(
  anim: GsapAnimation,
  resolvedFromValues?: Record<string, number | string>,
)

Source from the content-addressed store, hash-verified

481 * - For fromTo(): merges into toProps (the 100% endpoint the user is editing).
482 */
483export function resolveConversionProps(
484 anim: GsapAnimation,
485 resolvedFromValues?: Record<string, number | string>,
486): { fromProps: Record<string, number | string>; toProps: Record<string, number | string> } {
487 if (anim.method === "set") {
488 // A static hold becomes a keyframed `to` whose 0% and 100% both start at the
489 // set's value — the visual is unchanged until the user edits a keyframe to
490 // animate it. (The caller flips the call from `set` to `to` + adds a duration.)
491 return { fromProps: { ...anim.properties }, toProps: { ...anim.properties } };
492 }
493 if (anim.method === "to") {
494 const identity = buildIdentityMap(anim.properties);
495 const fromProps = resolvedFromValues ? { ...identity, ...resolvedFromValues } : identity;
496 return { fromProps, toProps: { ...anim.properties } };
497 }
498 if (anim.method === "from") {
499 const identity = buildIdentityMap(anim.properties);
500 const toProps = resolvedFromValues ? { ...identity, ...resolvedFromValues } : identity;
501 return { fromProps: { ...anim.properties }, toProps };
502 }
503 // fromTo(fromVars, toVars): anim.fromProperties = fromVars (0% state),
504 // anim.properties = toVars (100% state). resolvedFromValues contains the
505 // current DOM position from a drag — it represents the NEW destination, so
506 // it merges into toProps (the 100% endpoint the user is editing), NOT into
507 // fromProps. This is intentional and not inverted.
508 const toProps = resolvedFromValues
509 ? { ...anim.properties, ...resolvedFromValues }
510 : { ...anim.properties };
511 return { fromProps: { ...(anim.fromProperties ?? {}) }, toProps };
512}
513
514// ── Arc path serialization helpers (shared by recast + acorn writers) ─────────
515

Callers 2

Calls 1

buildIdentityMapFunction · 0.85

Tested by

no test coverage detected