adjust browser viewport to avoid cutting off bottom of page (#614)

- subtract the browser ui height from default viewport computed from
screen dimensions
- hard-code height to 81px for now
- fixes #613, bottom of page being cut-off as viewport height was too
big
This commit is contained in:
Ilya Kreymer 2024-06-14 15:25:59 -07:00 committed by GitHub
parent ff481855d5
commit ac722cc856
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -42,6 +42,10 @@ type LaunchOpts = {
recording: boolean;
};
// fixed height of the browser UI (may need to be adjusted in the future)
// todo: a way to determine this?
const BROWSER_HEIGHT_OFFSET = 81;
// ==================================================================
export class Browser {
profileDir: string;
@ -94,7 +98,10 @@ export class Browser {
if (process.env.GEOMETRY) {
const geom = process.env.GEOMETRY.split("x");
defaultViewport = { width: Number(geom[0]), height: Number(geom[1]) };
defaultViewport = {
width: Number(geom[0]),
height: Number(geom[1]) - (recording ? 0 : BROWSER_HEIGHT_OFFSET),
};
}
const launchOpts: PuppeteerLaunchOptions = {