Initial commit 🚀
This commit is contained in:
commit
fd58a8d32f
235 files changed
+19775
No files matched your search
@@ -0,0 +1,16 @@
|
||||
import { chromium } from 'playwright';
|
||||
/* Scrolls a target into view and captures it at several moments, to see a draw-in happen. */
|
||||
const [,, url, prefix, selector, width = '1440', times = '150,700,1600,3200'] = process.argv;
|
||||
const browser = await chromium.launch();
|
||||
const page = await browser.newPage({ viewport: { width: Number(width), height: 900 } });
|
||||
await page.goto(url, { waitUntil: 'networkidle' });
|
||||
const el = page.locator(selector).first();
|
||||
await el.scrollIntoViewIfNeeded();
|
||||
const t0 = Date.now();
|
||||
for (const t of times.split(',').map(Number)) {
|
||||
const wait = t - (Date.now() - t0);
|
||||
if (wait > 0) await page.waitForTimeout(wait);
|
||||
await el.screenshot({ path: `${prefix}-${t}.png` });
|
||||
}
|
||||
await browser.close();
|
||||
console.log('captured', selector);
|
||||
Reference in new issue
Block a user