File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
packages/image-comparison-core/src/methods Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -401,6 +401,14 @@ export async function getDesktopFullPageScreenshotsData(browserInstance:Webdrive
401401 imageYPosition = remainingContent >= actualInnerHeight
402402 ? safariTopDropShadowCssPixels
403403 : actualInnerHeight - remainingContent - safariBottomCropOffsetCssPixels
404+
405+ // If remainingContent is too small, we might get negative imageYPosition or invalid dimensions
406+ if ( imageYPosition < 0 ) {
407+ imageYPosition = actualInnerHeight - remainingContent
408+ imageHeight = remainingContent
409+ } else if ( imageYPosition + imageHeight > screenshotSize . height ) {
410+ imageHeight = screenshotSize . height - imageYPosition
411+ }
404412 } else if ( ! isFirstImage ) {
405413 // Non-last, non-first images: crop 1px from top
406414 imageYPosition = safariTopDropShadowCssPixels
@@ -414,6 +422,15 @@ export async function getDesktopFullPageScreenshotsData(browserInstance:Webdrive
414422 : 0
415423 }
416424
425+ // Ensure imageYPosition and imageHeight are valid for all cases
426+ if ( imageYPosition < 0 ) {
427+ imageHeight += imageYPosition
428+ imageYPosition = 0
429+ }
430+ if ( imageYPosition + imageHeight > screenshotSize . height ) {
431+ imageHeight = screenshotSize . height - imageYPosition
432+ }
433+
417434 // Calculate based on where the previous image ends
418435 // Previous image's canvasYPosition + previous image's height
419436 let canvasYPosition : number
You can’t perform that action at this time.
0 commit comments