Skip to content

Commit

Permalink
viewport parsing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aferditamuriqi committed Feb 28, 2024
1 parent 95d7def commit 0406883
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions src/navigator/IFrameNavigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1708,8 +1708,8 @@ export class IFrameNavigator extends EventEmitter implements Navigator {
e instanceof Error
? e
: typeof e === "string"
? new Error(e)
: new Error("An unknown error occurred in the IFrameNavigator.");
? new Error(e)
: new Error("An unknown error occurred in the IFrameNavigator.");
this.api.onError(trueError);
} else {
// otherwise just display the standard error UI
Expand Down Expand Up @@ -2118,8 +2118,8 @@ export class IFrameNavigator extends EventEmitter implements Navigator {
height = getComputedStyle(doc.body).height;
width = getComputedStyle(doc.body).width;
if (
parseInt(height?.replace("px", "")) === 0 ||
parseInt(width?.replace("px", "")) === 0
parseInt(height.toString().replace("px", "")) === 0 ||
parseInt(width.toString().replace("px", "")) === 0
) {
const head = HTMLUtilities.findIframeElement(
doc,
Expand Down Expand Up @@ -2152,11 +2152,11 @@ export class IFrameNavigator extends EventEmitter implements Navigator {
var widthRatio =
(parseInt(getComputedStyle(iframeParent).width) - 100) /
(this.iframes.length === 2
? parseInt(width?.replace("px", "")) * 2 + 200
: parseInt(width?.replace("px", "")));
? parseInt(width.toString().replace("px", "")) * 2 + 200
: parseInt(width.toString().replace("px", "")));
var heightRatio =
(parseInt(getComputedStyle(iframeParent).height) - 100) /
parseInt(height?.replace("px", ""));
parseInt(height.toString().replace("px", ""));
var scale = Math.min(widthRatio, heightRatio);
iframeParent.style.transform = "scale(" + scale + ")";
for (const iframe of this.iframes) {
Expand Down Expand Up @@ -2617,10 +2617,10 @@ export class IFrameNavigator extends EventEmitter implements Navigator {
return obj;
}, {});
if (parseInt(obj["height"]) !== 0 || parseInt(obj["width"]) !== 0) {
height = obj["height"].endsWith("px")
height = obj["height"].toString().endsWith("px")
? obj["height"]
: obj["height"] + "px";
width = obj["width"].endsWith("px")
width = obj["width"].toString().endsWith("px")
? obj["width"]
: obj["width"] + "px";
}
Expand All @@ -2630,11 +2630,21 @@ export class IFrameNavigator extends EventEmitter implements Navigator {
var widthRatio =
(parseInt(getComputedStyle(iframeParent).width) - 100) /
(this.iframes.length === 2
? parseInt(width?.replace("px", "")) * 2 + 200
: parseInt(width?.replace("px", "")));
? parseInt(
width.toString().endsWith("px")
? width?.replace("px", "")
: width
) *
2 +
200
: parseInt(
width.toString().endsWith("px")
? width?.replace("px", "")
: width
));
var heightRatio =
(parseInt(getComputedStyle(iframeParent).height) - 100) /
parseInt(height?.replace("px", ""));
parseInt(height.toString().replace("px", ""));
var scale = Math.min(widthRatio, heightRatio);
iframeParent.style.transform = "scale(" + scale + ")";

Expand Down

0 comments on commit 0406883

Please sign in to comment.