From 2bdab36d7a254a68a1523b5c5b91a8e2eeb29889 Mon Sep 17 00:00:00 2001 From: wadackel Date: Sat, 18 Jun 2022 15:39:55 +0900 Subject: [PATCH] fix: fix `disableCssAnimation` bug when using multiple viewports --- packages/storycap/src/node/capturing-browser.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/storycap/src/node/capturing-browser.ts b/packages/storycap/src/node/capturing-browser.ts index 3a580d870..0707705b7 100644 --- a/packages/storycap/src/node/capturing-browser.ts +++ b/packages/storycap/src/node/capturing-browser.ts @@ -109,6 +109,12 @@ export class CapturingBrowser extends StoryPreviewBrowser { Object.entries(exposed).forEach(([k, f]) => this.page.exposeFunction(k, f)); } + private async reload() { + await this.page.reload(); + await sleep(this.opt.viewportDelay); + await this.addStyles(); + } + private async waitIfTouched() { if (!this.touched) return; await sleep(this.opt.stateChangeDelay); @@ -255,7 +261,7 @@ export class CapturingBrowser extends StoryPreviewBrowser { this.viewport = nextViewport; if (willBeReloaded || this.opt.reloadAfterChangeViewport) { this.processedStories.delete(this.currentRequestId); - await Promise.all([this.page.reload(), this.waitForOptionsFromBrowser()]); + await Promise.all([this.reload(), this.waitForOptionsFromBrowser()]); } else { await sleep(this.opt.viewportDelay); }