Skip to content

Commit 6f9ff69

Browse files
fix(core): remove data-position-mode gate — clip-relative offsets apply unconditionally
Co-authored-by: Miguel Ángel <miguel07alm@protonmail.com>
1 parent 50a3a34 commit 6f9ff69

4 files changed

Lines changed: 1 addition & 55 deletions

File tree

packages/core/src/generators/hyperframes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ export function generateHyperframesHtml(
354354
const gsapCdnTag = includeScripts ? ` <script src="${GSAP_CDN}"></script>` : "";
355355

356356
const gsapScriptTag = includeScripts
357-
? ` <script data-position-mode="relative">
357+
? ` <script>
358358
${gsapScript}
359359
</script>`
360360
: "";

packages/core/src/runtime/init.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,6 @@ export function initSandboxRuntimeModular(): void {
988988
};
989989

990990
const applyClipRelativeOffsets = (timeline: RuntimeTimelineLike) => {
991-
if (!document.querySelector("script[data-position-mode='relative']")) return;
992991
try {
993992
applyOffsets(timeline as never, (el) => resolveStartForElement(el, 0));
994993
} catch (err) {

packages/core/src/studio-api/routes/files.test.ts

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -542,54 +542,4 @@ const tl = gsap.timeline();
542542
// The variable target was not flattened to a string-literal selector
543543
expect(result.after).toContain("tl.to(kicker,");
544544
});
545-
546-
it("stamps data-position-mode='relative' on the script tag after any mutation", async () => {
547-
const projectDir = createProjectDir();
548-
const html = `<!DOCTYPE html><html><body>
549-
<div id="hero" data-start="0" data-duration="4"></div>
550-
<script>
551-
const tl = gsap.timeline();
552-
tl.to("#hero", { x: 100, duration: 2 }, 0);
553-
</script></body></html>`;
554-
writeHtml(projectDir, "index.html", html);
555-
const app = new Hono();
556-
registerFileRoutes(app, createAdapter(projectDir));
557-
558-
const anim = await getFirstAnimation(app, "index.html");
559-
const res = await app.request("http://localhost/projects/demo/gsap-mutations/index.html", {
560-
method: "POST",
561-
headers: { "Content-Type": "application/json" },
562-
body: JSON.stringify({ type: "update-meta", animationId: anim.id, updates: { position: 1 } }),
563-
});
564-
const result = (await res.json()) as { ok: boolean; after: string };
565-
566-
expect(res.status).toBe(200);
567-
expect(result.ok).toBe(true);
568-
expect(result.after).toContain('data-position-mode="relative"');
569-
});
570-
571-
it("does not duplicate data-position-mode on subsequent mutations", async () => {
572-
const projectDir = createProjectDir();
573-
const html = `<!DOCTYPE html><html><body>
574-
<div id="hero" data-start="0" data-duration="4"></div>
575-
<script data-position-mode="relative">
576-
const tl = gsap.timeline();
577-
tl.to("#hero", { x: 100, duration: 2 }, 0);
578-
</script></body></html>`;
579-
writeHtml(projectDir, "index.html", html);
580-
const app = new Hono();
581-
registerFileRoutes(app, createAdapter(projectDir));
582-
583-
const anim = await getFirstAnimation(app, "index.html");
584-
const res = await app.request("http://localhost/projects/demo/gsap-mutations/index.html", {
585-
method: "POST",
586-
headers: { "Content-Type": "application/json" },
587-
body: JSON.stringify({ type: "update-meta", animationId: anim.id, updates: { position: 1 } }),
588-
});
589-
const result = (await res.json()) as { ok: boolean; after: string };
590-
591-
expect(res.status).toBe(200);
592-
const matches = result.after.match(/data-position-mode/g);
593-
expect(matches).toHaveLength(1);
594-
});
595545
});

packages/core/src/studio-api/routes/files.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,9 +1178,6 @@ export function registerFileRoutes(api: Hono, adapter: StudioApiAdapter): void {
11781178

11791179
const newScript = typeof result === "string" ? result : result.script;
11801180
const changed = newScript !== block.scriptText;
1181-
if (changed && !block.scriptElement.hasAttribute("data-position-mode")) {
1182-
block.scriptElement.setAttribute("data-position-mode", "relative");
1183-
}
11841181
const newHtml = changed ? block.replaceScript(newScript) : html;
11851182
let backupPath: string | null = null;
11861183
if (changed) {

0 commit comments

Comments
 (0)