Skip to content

Commit 325491e

Browse files
committed
Reload if the scale changes
1 parent f2dc65b commit 325491e

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

app/scripts/core/gameCoordinator.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,7 @@ class GameCoordinator {
708708
window.addEventListener('addTimer', this.addTimer.bind(this));
709709
window.addEventListener('removeTimer', this.removeTimer.bind(this));
710710
window.addEventListener('releaseGhost', this.releaseGhost.bind(this));
711+
this.registerResizeListener();
711712

712713
const directions = ['up', 'down', 'left', 'right'];
713714

@@ -720,6 +721,22 @@ class GameCoordinator {
720721
});
721722
}
722723

724+
registerResizeListener() {
725+
let timer = null;
726+
window.addEventListener('resize', () => {
727+
if (timer) {
728+
clearTimeout(timer);
729+
timer = null;
730+
}
731+
732+
timer = setTimeout(() => {
733+
if (this.scale !== this.determineScale(1)) {
734+
window.location.reload();
735+
}
736+
}, 100);
737+
});
738+
}
739+
723740
/**
724741
* Calls Pacman's changeDirection event if certain conditions are met
725742
* @param {({'up'|'down'|'left'|'right'})} direction

0 commit comments

Comments
 (0)