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

Function cascadeRemoveAnimations

packages/sdk/src/engine/mutate.ts:892–907  ·  view source on GitHub ↗
(script: string, id: HfId)

Source from the content-addressed store, hash-verified

890}
891
892function cascadeRemoveAnimations(script: string, id: HfId): string {
893 // Re-parse after each removal: animation ids are positional, so removing one
894 // tween renumbers the survivors — ids from a single up-front parse go stale and
895 // no-op, orphaning later tweens on the removed element. Same fix as
896 // stripGsapForId in htmlParser.ts (R3 #3); this is its SDK-side twin.
897 let current = script;
898 for (;;) {
899 const parsedGsap = parseGsapScriptAcornForWrite(current);
900 if (!parsedGsap) return current;
901 const match = parsedGsap.located.find((l) => selectorMatchesId(l.animation.targetSelector, id));
902 if (!match) return current;
903 const next = removeAnimationFromScript(current, match.id);
904 if (next === current) return current; // guard against a non-removing match
905 current = next;
906 }
907}
908
909// ─── addWithKeyframes / replaceWithKeyframes handlers ────────────────────────
910

Callers 1

handleRemoveElementFunction · 0.85

Calls 4

selectorMatchesIdFunction · 0.85
findMethod · 0.65

Tested by

no test coverage detected