@pygmalionjs/pygmalion 0.6.5 → 0.6.7

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.
@@ -423,6 +423,39 @@ export async function runStoryboardInteraction(page, interaction) {
423
423
  return;
424
424
  }
425
425
 
426
+ if (interaction.action === 'scroll') {
427
+ const position = {
428
+ x: Number.isFinite(interaction.scrollX) ? Math.max(0, interaction.scrollX) : null,
429
+ y: Number.isFinite(interaction.scrollY) ? Math.max(0, interaction.scrollY) : null,
430
+ };
431
+ if (interaction.selector || interaction.text) {
432
+ const timeoutMs = interaction.timeoutMs ?? 5_000;
433
+ const target = await waitForCandidateLocator(
434
+ page,
435
+ interaction,
436
+ timeoutMs,
437
+ );
438
+ if (!(await targetExists(target, Math.min(timeoutMs, 500)))) {
439
+ throw new Error(`"${interaction.label}" scroll target was not found.`);
440
+ }
441
+ await target.evaluate((element, next) => {
442
+ const left = next.x ?? element.scrollLeft;
443
+ const top = next.y ?? element.scrollTop;
444
+ if (typeof element.scrollTo === 'function') element.scrollTo(left, top);
445
+ else {
446
+ element.scrollLeft = left;
447
+ element.scrollTop = top;
448
+ }
449
+ }, position);
450
+ } else {
451
+ await page.evaluate((next) => {
452
+ window.scrollTo(next.x ?? window.scrollX, next.y ?? window.scrollY);
453
+ }, position);
454
+ }
455
+ await page.waitForTimeout(interaction.settleMs ?? 100);
456
+ return;
457
+ }
458
+
426
459
  const timeoutMs = interaction.timeoutMs ?? 5_000;
427
460
  const target = await waitForCandidateLocator(page, interaction, timeoutMs);
428
461
  if (!(await targetExists(target, Math.min(timeoutMs, 500)))) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pygmalionjs/pygmalion",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
4
4
  "description": "Code-backed DOM design sandbox and visual QA editor",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {