Skip to content

Commit

Permalink
Fix the issue where the window resize does not match the iframe's siz…
Browse files Browse the repository at this point in the history
…e on the web platform
  • Loading branch information
JiepengTan committed Nov 15, 2024
1 parent 3e1750d commit 7d8d2f5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
19 changes: 17 additions & 2 deletions platform/web/js/libs/library_godot_display.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,23 @@ const GodotDisplayScreen = {
width = window.innerWidth * scale;
height = window.innerHeight * scale;
}
const csw = `${width / scale}px`;
const csh = `${height / scale}px`;
let csw = `${width / scale}px`;
let csh = `${height / scale}px`;

if (!(isFullscreen || wantsFullWindow)) {
const radio = dWidth / dHeight;
const displayWidth = window.innerWidth;
const displayHeight = window.innerHeight;
const winRadio = displayWidth / displayHeight;

if (winRadio > radio) {
csh = (displayHeight)/ scale + 'px';
csw = (displayHeight * radio)/ scale + 'px';
} else {
csw = (displayWidth)/ scale + 'px';
csh = (displayWidth / radio)/ scale + 'px';
}
}
if (canvas.style.width !== csw || canvas.style.height !== csh || canvas.width !== width || canvas.height !== height) {
// Size doesn't match.
// Resize canvas, set correct CSS pixel size, update GL.
Expand Down
1 change: 0 additions & 1 deletion test
Submodule test deleted from 7edb84

0 comments on commit 7d8d2f5

Please sign in to comment.