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

Function isTimedElementVisibleAt

packages/core/src/runtime/init.ts:513–550  ·  view source on GitHub ↗
(rawNode: HTMLElement, currentTime: number)

Source from the content-addressed store, hash-verified

511 };
512
513 const isTimedElementVisibleAt = (rawNode: HTMLElement, currentTime: number): boolean => {
514 const tag = rawNode.tagName.toLowerCase();
515 if (tag === "script" || tag === "style" || tag === "link" || tag === "meta") {
516 return false;
517 }
518
519 const start =
520 tag === "video" || tag === "audio"
521 ? resolveMediaStartSeconds(rawNode, 0)
522 : resolveStartForElement(rawNode, 0);
523 let duration = resolveDurationForElement(rawNode);
524 const compId = rawNode.getAttribute("data-composition-id");
525 if (compId) {
526 const compTimeline = (window.__timelines ?? {})[compId];
527 let liveDuration: number | null = null;
528 if (compTimeline && typeof compTimeline.duration === "function") {
529 const compDur = Number(compTimeline.duration());
530 if (Number.isFinite(compDur) && compDur > 0) {
531 liveDuration = compDur;
532 }
533 }
534
535 const hasAuthoredTiming =
536 rawNode.hasAttribute("data-duration") ||
537 rawNode.hasAttribute("data-end") ||
538 rawNode.hasAttribute(AUTHORED_DURATION_ATTR) ||
539 rawNode.hasAttribute(AUTHORED_END_ATTR);
540
541 if (!hasAuthoredTiming && (duration == null || duration <= 0) && liveDuration != null) {
542 duration = liveDuration;
543 }
544 }
545 const computedEnd =
546 duration != null && duration > 0 ? start + duration : Number.POSITIVE_INFINITY;
547 return (
548 currentTime >= start && (Number.isFinite(computedEnd) ? currentTime <= computedEnd : true)
549 );
550 };
551
552 const hasExternalCompositions = !!document.querySelector("[data-composition-src]");
553 let hasInlineTemplateCompositions = false;

Callers 1

syncMediaForCurrentStateFunction · 0.85

Calls 6

resolveMediaStartSecondsFunction · 0.85
resolveStartForElementFunction · 0.85
getAttributeMethod · 0.65
durationMethod · 0.65
hasAttributeMethod · 0.65

Tested by

no test coverage detected