Skip to content

Commit

Permalink
Finally fix game scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Suarez committed Nov 22, 2024
1 parent 0800022 commit f77bd7b
Showing 1 changed file with 22 additions and 27 deletions.
49 changes: 22 additions & 27 deletions docs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,31 @@ function resizeGame() {
function loadGame(game) {
const container = document.querySelector('.featured-game-container');
const featured = document.querySelector('.featured-game');

// Set container size
container.style.width = `${game.width}px`;
container.style.height = `${game.height}px`;

// Set iframe size
featured.style.width = `${game.width}px`;
featured.style.height = `${game.height}px`;

// Also set the attributes for good measure
featured.width = game.width;
featured.height = game.height;

console.log('Container resized to:', {
containerWidth: container.clientWidth,
containerHeight: container.clientHeight,
iframeWidth: featured.clientWidth,
iframeHeight: featured.clientHeight,
containerVisible: container.offsetParent !== null
});


featured.src = game.path;
document.querySelector('.game-info .game-title').textContent = game.title;
document.querySelector('.game-description').textContent = game.description;

}

function initializeGames() {
Expand Down Expand Up @@ -61,32 +81,7 @@ function randomizeGame() {
do {
newGame = gameEntries[Math.floor(Math.random() * gameEntries.length)][1];
} while (newGame.path === currentPath);

const container = document.querySelector('.featured-game-container');

// Set container size
container.style.width = `${newGame.width}px`;
container.style.height = `${newGame.height}px`;

// Set iframe size
currentGame.style.width = `${newGame.width}px`;
currentGame.style.height = `${newGame.height}px`;
// Also set the attributes for good measure
currentGame.width = newGame.width;
currentGame.height = newGame.height;

// Set source and text content last
currentGame.src = newGame.path;
document.querySelector('.game-info .game-title').textContent = newGame.title;
document.querySelector('.game-description').textContent = newGame.description;

console.log('Container resized to:', {
containerWidth: container.clientWidth,
containerHeight: container.clientHeight,
iframeWidth: currentGame.clientWidth,
iframeHeight: currentGame.clientHeight,
containerVisible: container.offsetParent !== null
});
loadGame(newGame);
}

document.addEventListener('DOMContentLoaded', () => {
Expand Down

0 comments on commit f77bd7b

Please sign in to comment.