@bivy/bivy 0.19.1 → 0.19.2-staging.2
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/apps/screenshot.js +5 -2
- package/package.json +1 -1
package/dist/apps/screenshot.js
CHANGED
|
@@ -181,9 +181,12 @@ export async function takeShots(views, request, outDir, chrome = findChrome()) {
|
|
|
181
181
|
}
|
|
182
182
|
let scroll;
|
|
183
183
|
if (request.scroll) {
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
// Instant: a page's `scroll-behavior: smooth` would otherwise animate,
|
|
185
|
+
// so the position read (and the picture) would be mid-scroll.
|
|
186
|
+
await cdp.send("Runtime.evaluate", { expression: `scrollTo({left:${Number(request.scroll.x) || 0},top:${Number(request.scroll.y) || 0},behavior:'instant'})` }, sessionId);
|
|
186
187
|
await new Promise((r) => setTimeout(r, 150));
|
|
188
|
+
const { result } = await cdp.send("Runtime.evaluate", { expression: "[scrollX, scrollY]", returnByValue: true }, sessionId);
|
|
189
|
+
scroll = { x: Number(result?.value?.[0]) || 0, y: Number(result?.value?.[1]) || 0 };
|
|
187
190
|
}
|
|
188
191
|
const { data } = await cdp.send("Page.captureScreenshot", { format: "png" }, sessionId);
|
|
189
192
|
const file = path.join(outDir, `${entry.view.id.slice(0, 8)}-${width}-${theme}.png`);
|