Skip to content

Commit

Permalink
fix(plugins): track correct screen size in chrome 98
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Mar 17, 2022
1 parent 65ce67d commit c2fecdc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugins/default-browser-emulator/lib/helpers/setScreensize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ export default async function setScreensize(
if (viewport.width === 0 || viewport.height === 0) {
promises.push(
devtools.send('Page.getLayoutMetrics').then(x => {
viewport.height = x.visualViewport.clientHeight;
viewport.width = x.visualViewport.clientWidth;
viewport.deviceScaleFactor = x.visualViewport.scale;
// @ts-expect-error - chrome 98 add correctly sized cssVisualViewport.
const visualViewport: Protocol.Page.VisualViewport = x.cssVisualViewport ?? x.visualViewport;
viewport.height = visualViewport.clientHeight;
viewport.width = visualViewport.clientWidth;
viewport.deviceScaleFactor = visualViewport.scale;
return viewport;
}),
);
Expand Down

0 comments on commit c2fecdc

Please sign in to comment.