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
23 changes: 23 additions & 0 deletions packages/lint/src/rules/gsap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3056,6 +3056,29 @@ describe("SVG draw-on rules", () => {

expect(finding?.severity).toBe("warning");
expect(finding?.selector).toBe("#ring");
expect(finding?.fixHint).toContain("every fromTo except the earliest-positioned one (at 5s)");
expect(finding?.fixHint).toContain("gsap_timeline_set_initial_hide");
});

it("gsap_repeated_fromto_without_baseline: accepts the hinted shape when the later tween is authored first", async () => {
const html = `
<html><body>
<div data-composition-id="main" data-width="1920" data-height="1080"><div id="ring"></div></div>
<script src="https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js"></script>
<script>
window.__timelines = window.__timelines || {};
const tl = gsap.timeline({ paused: true });
tl.fromTo("#ring", { opacity: 1 }, { opacity: 0, duration: 0.5, immediateRender: false }, 10);
tl.fromTo("#ring", { opacity: 0 }, { opacity: 1, duration: 0.5 }, 5);
window.__timelines.main = tl;
</script>
</body></html>`;
const result = await lintHyperframeHtml(html);
const finding = result.findings.find(
(candidate) => candidate.code === "gsap_repeated_fromto_without_baseline",
);

expect(finding).toBeUndefined();
});

it("gsap_repeated_fromto_without_baseline: accepts explicit immediateRender false", async () => {
Expand Down
7 changes: 4 additions & 3 deletions packages/lint/src/rules/gsap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1148,9 +1148,10 @@ export const gsapRules: LintRule<LintContext>[] = [
`(immediateRender), not at tween position.`,
selector,
fixHint:
`Add \`immediateRender: false\` to the destination vars of each future fromTo, or set a safe ` +
`resting state with an earlier \`tl.set("${selector}", { ... }, 0)\`. Pre-first-tween seeks must not ` +
`inherit whichever fromTo call happened to author last.`,
`Add \`immediateRender: false\` to every fromTo except the earliest-positioned one ` +
`(at ${firstFromToPosition}s), so pre-first-tween seeks keep its "from" values. ` +
`A hiding \`tl.set(..., 0)\` baseline trips gsap_timeline_set_initial_hide, and a \`gsap.set\` ` +
`authored before the fromTo calls is overwritten by them.`,
snippet: truncateSnippet(fromToWindows.map((win) => win.raw).join("\n")),
});
}
Expand Down
Loading