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

Function attachComposedAncestors

packages/cli/src/commands/keyframes.ts:446–459  ·  view source on GitHub ↗
(tweens: SurfacedTween[], html: string)

Source from the content-addressed store, hash-verified

444// trajectory (e.g. a child carries a flap while the parent carries the path), so
445// annotate each tween with the animated ancestor elements above it in the DOM.
446function attachComposedAncestors(tweens: SurfacedTween[], html: string): void {
447 const animated = [...new Set(tweens.filter((t) => t.method !== "set").map((t) => t.target))];
448 if (animated.length < 2) return; // need ≥2 distinct animated elements to compose
449 const doc = new DOMParser().parseFromString(html, "text/html");
450 for (const t of tweens) {
451 const ancestors = animatedAncestors(doc, t.target, animated);
452 if (ancestors.length) {
453 t.composedWith = ancestors.map((sel) => ({
454 selector: sel,
455 summary: summarizeMotion(tweens, sel),
456 }));
457 }
458 }
459}
460
461const safeMatches = (el: Element, sel: string): boolean => {
462 try {

Callers 1

surfaceCompositionFunction · 0.85

Calls 2

animatedAncestorsFunction · 0.85
summarizeMotionFunction · 0.85

Tested by

no test coverage detected