Skip to content

Commit c32162a

Browse files
committed
fix: floating point precision in screenshot bounds check
Use Math.ceil on zoom-adjusted dimensions to prevent false rejections when innerWidth/Height * zoomFactor produces fractional values.
1 parent 986156e commit c32162a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/phoenix/shell.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,12 @@ async function _capturePageBinary(rectOrNodeOrSelector) {
209209
throw new Error("rect width and height must be greater than 0");
210210
}
211211
const zoomFactor = (window.PhStore && window.PhStore.getItem("desktopZoomScale")) || 1;
212-
if (rect.x + rect.width > window.innerWidth * zoomFactor) {
212+
const maxWidth = Math.ceil(window.innerWidth * zoomFactor);
213+
const maxHeight = Math.ceil(window.innerHeight * zoomFactor);
214+
if (rect.x + rect.width > maxWidth) {
213215
throw new Error("rect x + width exceeds window innerWidth");
214216
}
215-
if (rect.y + rect.height > window.innerHeight * zoomFactor) {
217+
if (rect.y + rect.height > maxHeight) {
216218
throw new Error("rect y + height exceeds window innerHeight");
217219
}
218220
}

0 commit comments

Comments
 (0)