Skip to content

Commit c7d2f86

Browse files
committed
fix(core): a Studio-stamped scene keeps animating after the root grows past its stamp
1 parent 461e252 commit c7d2f86

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

‎packages/core/src/runtime/init.subCompositionPlacement.test.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,31 @@ describe("runtime sub-composition placement", () => {
239239
expect(shownX()).toBe(75);
240240
});
241241

242+
it("keeps a slow scene Studio stamped animating past its stamp, once the root has grown", () => {
243+
const parent = window.parent;
244+
Object.defineProperty(window, "parent", { configurable: true, value: {} });
245+
try {
246+
// What Studio leaves after a root extension: the host's discovery stamp still ends at 10 s.
247+
document.body.innerHTML =
248+
`<div data-composition-id="main" data-root="true" data-duration="20">` +
249+
`<div id="host" style="position: absolute" data-composition-id="scene" data-playback-rate="0.5"` +
250+
` data-start="0" data-duration="10" data-hf-autostamped="1"><div id="s"></div></div></div>`;
251+
const scene = gsap
252+
.timeline({ paused: true })
253+
.to("#s", { x: 100, duration: 8, ease: "none" }, 0);
254+
const root = gsap.timeline({ paused: true }).to({}, { duration: 20 }, 0);
255+
window.__timelines = { main: root, scene } as unknown as Record<string, RuntimeTimelineLike>;
256+
initSandboxRuntimeModular();
257+
258+
window.__player?.seek(6);
259+
window.__player?.seek(12);
260+
expect(shownX()).toBe(75);
261+
expect(getComputedStyle(document.getElementById("host")!).visibility).not.toBe("hidden");
262+
} finally {
263+
Object.defineProperty(window, "parent", { configurable: true, value: parent });
264+
}
265+
});
266+
242267
it("renders a scene past its clip's end where root propagation leaves it, replaying no callbacks", () => {
243268
document.body.innerHTML =
244269
`<div data-composition-id="main" data-root="true" data-duration="10">` +

‎packages/core/src/runtime/init.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,9 @@ function loadPreviewImagesIn(root: Element): void {
433433
export function initSandboxRuntimeModular(): void {
434434
const state = createRuntimeState();
435435
const stampsForStudio = window.parent !== window;
436+
// Studio's discovery stamps time a clip for the timeline only; nothing hides it at their end.
437+
const isDiscoveryStamped = (el: Element) =>
438+
stampsForStudio && el.hasAttribute(RUNTIME_STAMPED_ATTR);
436439
authoredMediaObserver?.disconnect();
437440
authoredMediaObserver = null;
438441
if (readSceneParts(document)) recordAuthoredMedia(document.documentElement);
@@ -2959,7 +2962,7 @@ export function initSandboxRuntimeModular(): void {
29592962
visibleAt(rawNode, currentTime) &&
29602963
clipChainVisibleAt(rawNode.parentElement, currentTime, visibleAt, rootComp);
29612964
visibilityDecided.set(rawNode, isVisibleNow);
2962-
const isRuntimeStamped = stampsForStudio && rawNode.hasAttribute(RUNTIME_STAMPED_ATTR);
2965+
const isRuntimeStamped = isDiscoveryStamped(rawNode);
29632966
if (!isRuntimeStamped) rawNode.style.visibility = isVisibleNow ? "visible" : "hidden";
29642967
rawNode.toggleAttribute(CLIP_HIDDEN_ATTR, !isRuntimeStamped && !isVisibleNow);
29652968
const upcoming =
@@ -4432,7 +4435,7 @@ export function initSandboxRuntimeModular(): void {
44324435
if (!Number.isFinite(start)) continue;
44334436
// Rest only where the visibility pass hides the host and no rearmed root propagation moves it.
44344437
const hiddenFrom =
4435-
!options?.activateChildren && node.hasAttribute("data-start")
4438+
!options?.activateChildren && node.hasAttribute("data-start") && !isDiscoveryStamped(node)
44364439
? start + (resolveDurationForElement(node) ?? Infinity)
44374440
: Infinity;
44384441
const timelineDuration = getTimelineDurationSeconds(timeline);

0 commit comments

Comments
 (0)