Skip to content

Commit e2c18c7

Browse files
committed
fix(cli): judge a reversed animation's end in its own direction, and read plain timelines
1 parent 6778aaf commit e2c18c7

5 files changed

Lines changed: 31 additions & 14 deletions

File tree

‎docs/packages/cli.mdx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,9 @@ compliant colour you could use instead.
713713

714714
Severity is persistence-aware: a finding at a single sample demotes to info, a
715715
finding that persists gates the exit code, and a composition of 3s or more
716-
fails with `sweep_static` when its frame never changes and a GSAP or CSS
717-
animation on the page stayed stuck before its end, so the seek never drove it.
716+
fails with `sweep_static` when its frame never changes and a GSAP timeline or
717+
tween, or a CSS or Web animation, on the page held the same time without ever
718+
finishing, so the seek never drove it.
718719
Any other frame that never changes, such as a still title card, is a
719720
`sweep_static` warning ("Nothing on screen moved under seek"), and so is an
720721
audio-only advance; `--strict` fails the run on either. A composition that is

‎packages/cli/src/utils/checkBrowser.chromium.test.ts‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const PAGE = `<body>
1313
<div id="forever"></div>
1414
<div id="reverse"></div>
1515
<div id="held"></div>
16+
<div id="parked"></div>
17+
<div id="rewound"></div>
1618
<script>
1719
const clock = (total, at, reversed = false) => {
1820
let now = at;
@@ -40,6 +42,17 @@ const PAGE = `<body>
4042
const held = document.getElementById("held").animate([{ opacity: 0 }, { opacity: 1 }], { duration: 3000, fill: "forwards" });
4143
held.pause();
4244
held.currentTime = 3000;
45+
// Reversed and paused: at its end it has not started, at 0 it is complete.
46+
const backwards = (id, at) => {
47+
const animation = document.getElementById(id).animate([{ opacity: 0 }, { opacity: 1 }], { duration: 3000, fill: "both" });
48+
animation.playbackRate = -1;
49+
animation.pause();
50+
animation.currentTime = at;
51+
};
52+
backwards("parked", 3000);
53+
backwards("rewound", 0);
54+
// A registered timeline with only the one-iteration methods, which the runtime accepts.
55+
window.__timelines.partial = { duration: () => 4, time: () => 1 };
4356
</script>
4457
</body>`;
4558

@@ -74,17 +87,20 @@ describe.runIf(executablePath)("collectSeekClock in Chromium", () => {
7487
const second = await seekTo(2);
7588

7689
expect(first.map(({ time, done }) => [time, done])).toEqual([
90+
[1, false],
7791
[1, false],
7892
[0.2, true],
7993
[0, true],
8094
[1000, false],
8195
[0, true],
8296
[3000, true],
97+
[3000, false],
98+
[0, true],
8399
]);
84100
const [late, ...rest] = second;
85101
expect(rest.map(({ id }) => id)).toEqual(first.map(({ id }) => id));
86102
expect(first.map(({ id }) => id)).not.toContain(late?.id);
87-
expect(second.map(({ time }) => time)).toEqual([0, 2, 0.2, 0, 2000, 0, 3000]);
103+
expect(second.map(({ time }) => time)).toEqual([0, 2, 1, 0.2, 0, 2000, 0, 3000, 3000, 0]);
88104
await page.close();
89105
});
90106

‎packages/cli/src/utils/checkBrowser.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,8 @@ export async function collectSeekClock(page: Page): Promise<SeekClock[]> {
619619
// fallow-ignore-next-line complexity
620620
return page.evaluate(() => {
621621
type Clock = {
622+
duration?: () => unknown;
623+
time?: () => unknown;
622624
totalDuration?: () => unknown;
623625
totalTime?: () => unknown;
624626
totalProgress?: () => unknown;
@@ -642,21 +644,19 @@ export async function collectSeekClock(page: Page): Promise<SeekClock[]> {
642644
const gsapRoot = Reflect.get(Reflect.get(window, "gsap") ?? {}, "globalTimeline");
643645
const unregistered: unknown = gsapRoot?.getChildren?.(false, true, true) ?? [];
644646
for (const timeline of [...registered, ...(unregistered as unknown[])] as Clock[]) {
645-
const total = timeline?.totalDuration?.();
646-
if (timeline && typeof total === "number" && total > 0) {
647-
const progress = Number(timeline.totalProgress?.());
647+
const total = Number(timeline?.totalDuration?.() ?? timeline?.duration?.());
648+
if (timeline && total > 0) {
649+
const time = Number(timeline.totalTime?.() ?? timeline.time?.());
650+
const progress = Number(timeline.totalProgress?.() ?? time / total);
648651
const done = timeline.reversed?.() === true ? progress <= 0 : progress >= 1;
649-
clocks.push({ id: idOf(timeline), time: Number(timeline.totalTime?.()), done });
652+
clocks.push({ id: idOf(timeline), time, done });
650653
}
651654
}
652655
for (const animation of document.getAnimations?.() ?? []) {
653656
const time = Number(animation.currentTime ?? 0);
654657
const end = Number(animation.effect?.getComputedTiming().endTime ?? Number.POSITIVE_INFINITY);
655-
clocks.push({
656-
id: idOf(animation),
657-
time,
658-
done: animation.playState === "finished" || time >= end,
659-
});
658+
const atEnd = animation.playbackRate < 0 ? time <= 0 : time >= end;
659+
clocks.push({ id: idOf(animation), time, done: animation.playState === "finished" || atEnd });
660660
}
661661
return clocks;
662662
});

‎skills-manifest.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"files": 7
3131
},
3232
"hyperframes-cli": {
33-
"hash": "4138c685a2eaf3e9",
33+
"hash": "5076477812cf2c37",
3434
"files": 11
3535
},
3636
"hyperframes-core": {

‎skills/hyperframes-cli/references/lint-validate-inspect.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ One command, one Chrome boot. `check` runs the linter first and skips the browse
5050

5151
Every finding carries a selector, the element's `data-*` identity, the composition source file, a bbox, and the sample time: jump straight from the JSON to the HTML you must edit and re-run.
5252

53-
**Severity is persistence-aware.** A dynamic issue observed at a single grid sample (an entrance/exit transient) demotes to info and never gates. Issues held across samples gate the exit code, a held `content_overlap` is an error, and a held, partially-visible `canvas_overflow` breaching ≥5% of the canvas promotes to warning. Coordinate-frame findings (`escaped_container`, `panel_out_of_canvas`, `connector_detached`) flag geometry computed in one frame but rendered in another — an element far outside its offset parent, a painted panel stuck across the canvas edge, a connector line detached from every node. Text drawn into a `<canvas>` has no DOM box, so `canvas_overflow` cannot see it; `canvas_content_at_edge` warns when a canvas's pixels show sharp content (drawn text, hard shapes) along the frame edge — mark intentional full-bleed art (particles, photos) with `data-layout-allow-overflow`. If a 3s+ composition shows no visible change across every sample, `check` fails with `sweep_static`: a frame that never changes while a GSAP or CSS animation stays stuck before its end means the seek is not driving the page, so it refuses to pass. Any other frame that never changes (a still title card, an audio-only advance) is a warning that `--strict` fails; a composition meant to be still can take `data-no-timeline` on its root to skip it. The fingerprint includes per-element opacity, so opacity-only reveals (code typing, staggered fades) count as motion — but only while they're still in flight at the sampled times. The classic trap is a reveal that completes early and then holds a static frame for the rest of the duration: every sample lands on the settled state and check warns that nothing on screen moved (`--strict` fails it). Spread the reveal across the timeline or keep one continuously animated element alive (a blinking caret is idiomatic for code typing) — don't bolt on a slow position drift just to appease the check.
53+
**Severity is persistence-aware.** A dynamic issue observed at a single grid sample (an entrance/exit transient) demotes to info and never gates. Issues held across samples gate the exit code, a held `content_overlap` is an error, and a held, partially-visible `canvas_overflow` breaching ≥5% of the canvas promotes to warning. Coordinate-frame findings (`escaped_container`, `panel_out_of_canvas`, `connector_detached`) flag geometry computed in one frame but rendered in another — an element far outside its offset parent, a painted panel stuck across the canvas edge, a connector line detached from every node. Text drawn into a `<canvas>` has no DOM box, so `canvas_overflow` cannot see it; `canvas_content_at_edge` warns when a canvas's pixels show sharp content (drawn text, hard shapes) along the frame edge — mark intentional full-bleed art (particles, photos) with `data-layout-allow-overflow`. If a 3s+ composition shows no visible change across every sample, `check` fails with `sweep_static`: a frame that never changes while a GSAP timeline or tween, or a CSS or Web animation, holds the same time without ever finishing means the seek is not driving the page, so it refuses to pass. Any other frame that never changes (a still title card, an audio-only advance) is a warning that `--strict` fails; a composition meant to be still can take `data-no-timeline` on its root to skip it. The fingerprint includes per-element opacity, so opacity-only reveals (code typing, staggered fades) count as motion — but only while they're still in flight at the sampled times. The classic trap is a reveal that completes early and then holds a static frame for the rest of the duration: every sample lands on the settled state and check warns that nothing on screen moved (`--strict` fails it). Spread the reveal across the timeline or keep one continuously animated element alive (a blinking caret is idiomatic for code typing) — don't bolt on a slow position drift just to appease the check.
5454

5555
**Escape hatches** (mark intent in the HTML, then re-run):
5656

0 commit comments

Comments
 (0)