@pygmalionjs/pygmalion 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist-lib/testing.js
CHANGED
|
@@ -66,15 +66,18 @@ Pygmalion discovers visible CSS animation owners, animated pseudo elements,
|
|
|
66
66
|
matching animation rules, and Web Animations API targets while it serializes a
|
|
67
67
|
screen. It stamps every target into the inert preview and lists them under
|
|
68
68
|
**Motion**. Reviewers can play all motion together, isolate one target, pause
|
|
69
|
-
it, reset it to the deterministic
|
|
69
|
+
it, reset it to the deterministic visual baseline, or scrub through one cycle
|
|
70
70
|
with the Phase control.
|
|
71
71
|
|
|
72
72
|
Motion discovery has no semantic or size threshold. Small progress dots,
|
|
73
73
|
ordinary status indicators, shimmer bars, and full-surface animation receive
|
|
74
|
-
the same control. The default preview
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
the same control. The default preview holds finite animations at their terminal
|
|
75
|
+
state and repeating animations at the start of their cycle. This keeps entrance
|
|
76
|
+
motion from hiding the base UI while screenshots and visual comparisons remain
|
|
77
|
+
repeatable. Play, Pause, or Phase explicitly enters the motion timeline at the
|
|
78
|
+
selected phase; Reset restores the visual baseline. Using a Motion control
|
|
79
|
+
temporarily switches an imported frame back to its source DOM preview,
|
|
80
|
+
including while the editor is in Editing mode.
|
|
78
81
|
|
|
79
82
|
An animation does not need duplicate frames merely to show several points in
|
|
80
83
|
its cycle. Preserve a separate frame only when the motion ends in an independent
|
|
@@ -94,11 +94,40 @@ function throwIfAborted(signal) {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Holds one-shot motion at its terminal visual state while keeping repeating
|
|
99
|
+
* motion at a deterministic cycle origin. A frozen screen is the review
|
|
100
|
+
* baseline, so an entrance animation must not make its own content disappear.
|
|
101
|
+
*
|
|
102
|
+
* This function runs through page.evaluate and must remain self-contained.
|
|
103
|
+
*/
|
|
104
|
+
export function settleStoryboardAnimations() {
|
|
98
105
|
for (const animation of document.getAnimations?.({ subtree: true }) ?? []) {
|
|
99
106
|
try {
|
|
100
107
|
animation.pause();
|
|
101
|
-
|
|
108
|
+
const timing = animation.effect?.getComputedTiming?.();
|
|
109
|
+
const computedEndTime = Number(timing?.endTime);
|
|
110
|
+
if (Number.isFinite(computedEndTime)) {
|
|
111
|
+
animation.currentTime = Math.max(0, computedEndTime);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (computedEndTime === Number.POSITIVE_INFINITY) {
|
|
115
|
+
animation.currentTime = 0;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Browser timing objects expose endTime, but the fallback keeps custom
|
|
120
|
+
// Animation implementations and older engines deterministic as well.
|
|
121
|
+
const duration = Number(timing?.duration);
|
|
122
|
+
const iterations =
|
|
123
|
+
timing?.iterations == null ? 1 : Number(timing.iterations);
|
|
124
|
+
const delay = Number(timing?.delay ?? 0);
|
|
125
|
+
const endDelay = Number(timing?.endDelay ?? 0);
|
|
126
|
+
const fallbackEndTime =
|
|
127
|
+
delay + duration * Math.max(0, iterations) + endDelay;
|
|
128
|
+
animation.currentTime = Number.isFinite(fallbackEndTime)
|
|
129
|
+
? Math.max(0, fallbackEndTime)
|
|
130
|
+
: 0;
|
|
102
131
|
} catch {
|
|
103
132
|
// An animation owned by an unavailable timeline remains CSS-paused.
|
|
104
133
|
}
|
|
@@ -112,7 +141,7 @@ async function freezeStoryboardMotion(page, addStyle = true) {
|
|
|
112
141
|
element.setAttribute('data-pygmalion-preview', 'frozen');
|
|
113
142
|
});
|
|
114
143
|
}
|
|
115
|
-
await page.evaluate(
|
|
144
|
+
await page.evaluate(settleStoryboardAnimations);
|
|
116
145
|
}
|
|
117
146
|
|
|
118
147
|
async function atCaptureStage(stage, task, details = {}) {
|