Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/core/src/compiler/htmlBundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,13 @@ export function prepareFlattenedInnerRoot(innerRoot: Element): Element {
prepared.setAttribute("data-hf-authored-id", authoredRootId);
}
prepared.setAttribute("data-hf-inner-root", "true");
const w = prepared.getAttribute("data-width");
const h = prepared.getAttribute("data-height");
const widthVal = w ? `${w}px` : "100%";
const heightVal = h ? `${h}px` : "100%";
const existingStyle = (prepared.getAttribute("style") || "").trim();
const fill = `width:${widthVal};height:${heightVal}`;
prepared.setAttribute("style", existingStyle ? `${existingStyle};${fill}` : fill);
return prepared;
}

Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/runtime/compositionLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ function prepareFlattenedInnerRoot(innerRoot: HTMLElement): HTMLElement {
prepared.setAttribute("data-hf-authored-id", authoredRootId);
}
prepared.setAttribute("data-hf-inner-root", "true");
const w = prepared.getAttribute("data-width");
const h = prepared.getAttribute("data-height");
prepared.style.width = w ? `${w}px` : "100%";
prepared.style.height = h ? `${h}px` : "100%";
return prepared;
}

Expand Down
12 changes: 12 additions & 0 deletions packages/producer/tests/sub-comp-height-percent/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "Sub-composition height:100% centering",
"description": "Verifies that sub-compositions using height:100% + flexbox centering render content centered, not stuck at the top. Regression test for the data-hf-inner-root wrapper missing explicit dimensions.",
"tags": ["sub-composition", "regression", "layout", "centering"],
"minPsnr": 20,
"maxFrameFailures": 10,
"minAudioCorrelation": 0.0,
"maxAudioLagWindows": 120,
"renderConfig": {
"fps": 24
}
}
368 changes: 368 additions & 0 deletions packages/producer/tests/sub-comp-height-percent/output/compiled.html

Large diffs are not rendered by default.

Git LFS file not shown
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<template>
<div data-composition-id="centered-card" data-width="1920" data-height="1080">
<style>
[data-composition-id="centered-card"] {
width: 1920px;
height: 1080px;
overflow: hidden;
position: relative;
background: #ffffff;
}
[data-composition-id="centered-card"] .wrapper {
width: 100%;
height: 100%;
position: relative;
}
[data-composition-id="centered-card"] .center-box {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
[data-composition-id="centered-card"] .card {
width: 600px;
height: 200px;
background: #ea4c89;
border-radius: 24px;
display: flex;
align-items: center;
justify-content: center;
}
[data-composition-id="centered-card"] .card-text {
font-family: sans-serif;
font-size: 64px;
font-weight: 700;
color: #ffffff;
}
</style>

<div class="wrapper">
<div class="center-box">
<div class="card">
<span class="card-text">Centered</span>
</div>
</div>
</div>

<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
<script>
(function () {
window.__timelines = window.__timelines || {};
var tl = gsap.timeline({ paused: true });
var S = '[data-composition-id="centered-card"] ';
tl.fromTo(S + '.card', { scale: 0.8, opacity: 0 }, { scale: 1, opacity: 1, duration: 0.5, ease: 'power2.out' }, 0);
window.__timelines['centered-card'] = tl;
})();
</script>
</div>
</template>
19 changes: 19 additions & 0 deletions packages/producer/tests/sub-comp-height-percent/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
<style>
body { margin: 0; width: 1920px; height: 1080px; overflow: hidden; background: #000; }
</style>
</head>
<body>
<div data-composition-id="main" data-start="0" data-duration="3" data-width="1920" data-height="1080">
<div data-composition-id="centered-card" data-composition-src="centered-card.html" data-start="0" data-duration="3" data-track-index="0" data-width="1920" data-height="1080"></div>
</div>
<script>
window.__timelines = window.__timelines || {};
window.__timelines["main"] = gsap.timeline({ paused: true });
</script>
</body>
</html>
Loading