Skip to content

Commit 0acdf51

Browse files
committed
fix: restore scroll position in case DPR changes and throws
1 parent 534aa09 commit 0acdf51

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/browser/screen-shooter/elements-screen-shooter.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,10 @@ export class ElementsScreenShooter {
667667
perfDebug(`capture attempt (${attemptMode}): begin`);
668668
try {
669669
await this._scrollThroughCaptureArea(targetsToCapture, targetsToIgnore, page, opts, async currentState => {
670+
if (currentState.scrollOffset !== page.scrollOffset) {
671+
shouldRestoreScrollPosition = true;
672+
}
673+
670674
if (currentState.captureSpecs.length === 0) {
671675
if (iterations > 0) {
672676
debug(
@@ -760,10 +764,6 @@ export class ElementsScreenShooter {
760764
hasCapturedTheWholeArea = movingCaptureSpecs.every(s => getBottom(s.full) <= getBottom(newSafeArea));
761765
isOverflowingViewport = newCaptureSpecs.some(s => getBottom(s.full) > page.viewportSize.height);
762766

763-
if (currentState.scrollOffset !== page.scrollOffset) {
764-
shouldRestoreScrollPosition = true;
765-
}
766-
767767
debug("newCaptureSpecs: %O", newCaptureSpecs);
768768
debug("newSafeArea: %O", newSafeArea);
769769
debug("lastState.captureSpecs: %O", lastState.captureSpecs);

0 commit comments

Comments
 (0)