mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-10-30 09:16:55 +00:00
fix(lint): point the repeated fromTo baseline hint at immediateRender: false (#3895)
The repeated fromTo baseline lint hint now points at immediateRender: false. Hint text only; rule logic unchanged.
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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")),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user