storycap icon indicating copy to clipboard operation
storycap copied to clipboard

Does storycap cause browser resizing?

Open Jamie5 opened this issue 3 years ago • 3 comments

This is with storycap 3.1.8, puppeteer 14.2.1 (also seems to happen with puppeteer 9.1.1).

It seems like when capturing screenshots, storycap starts at 800x600 (I guess that is the default viewport), goes to the user-specified viewport, but during each screenshot, will resize to 1x1 before going back to the user-specified viewport. This is known due to logging from a window.resize event, the values of document.body.clientWidth and document.body.clientHeight. This causes problems for us due to using said values to do various throttled calculations. (we have potential workarounds, but it would be strange if this resizing is indeed going on)

Jamie5 avatar Jun 02 '22 22:06 Jamie5

Hi @Jamie5 The behavior you described(viewport being resized to 1x1) is causing an issue in my project as well. Would it be possible for you to share any potential workarounds or solutions you might have?

ysjn avatar Sep 08 '24 09:09 ysjn

I think in the cases of throttling we set throttle to 0 for storybook/storycap. I imagine one could also use act to observe the resize event to 1x1 and back before starting rendering (or otherwise with a short timeout), though this wasn't a path we needed to take.

Jamie5 avatar Sep 08 '24 15:09 Jamie5

Thank you very much for your prompt response! In my case, I was using window.innerWidth for some UI, which was disrupted by the 1px returned from Storycap Puppeteer. I will definitely try out the act method you mentioned. Thanks.

ysjn avatar Sep 09 '24 04:09 ysjn