mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
The off-canvas indicators (always mounted) and the Layers panel rebuild their layer list every 100 ms while a scrub mutates the preview, and each rebuild read the computed style of every element of every scene, on screen or not. The runtime already hides everything inside a clip its visibility pass hid, so those subtrees hold no layer: the walk now skips a clip marked data-hf-clip-hidden with an inline visibility of hidden. The marker constant moves to studio-preview-mark so the runtime and Studio share one owner.
32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { CLIP_HIDDEN_ATTR } from "../studioPreviewMark";
|
|
|
|
export { CLIP_HIDDEN_ATTR };
|
|
|
|
type ShaderWindow = Window & {
|
|
HyperShader?: unknown;
|
|
__hf?: { transitions?: unknown };
|
|
__hfClipRevealAware?: boolean;
|
|
};
|
|
|
|
/** Shows a clip the visibility pass hid, contents included; returns a function that puts the mark back. */
|
|
export function revealClip(el: Element & ElementCSSInlineStyle, priority = ""): () => void {
|
|
el.style.setProperty("visibility", "visible", priority);
|
|
if (!el.hasAttribute(CLIP_HIDDEN_ATTR)) return () => {};
|
|
el.removeAttribute(CLIP_HIDDEN_ATTR);
|
|
return function putClipHiddenMarkBack() {
|
|
el.setAttribute(CLIP_HIDDEN_ATTR, "");
|
|
};
|
|
}
|
|
|
|
/** Called by shader-transitions builds on load: their revealers go through revealClip. */
|
|
export function declareClipRevealAware(): void {
|
|
if (typeof window !== "undefined") (window as ShaderWindow).__hfClipRevealAware = true;
|
|
}
|
|
|
|
/** A shader-transitions build is on the page whose revealers predate revealClip. */
|
|
export function olderShaderBuildOnPage(): boolean {
|
|
const win = window as ShaderWindow;
|
|
const shaderOnPage = win.HyperShader !== undefined || win.__hf?.transitions !== undefined;
|
|
return shaderOnPage && win.__hfClipRevealAware !== true;
|
|
}
|