Skip to content

Commit

Permalink
feat(scenes): add event listener for window resize in Boot
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Jan 27, 2019
1 parent 1481bd9 commit bf23a18
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/scenes/Boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ export default class Boot extends Scene {

init() {
this.resize();
window.addEventListener('resize', this.resize);
}

resize() {
destroy() {
window.removeEventListener('resize', this.resize);
}

resize = () => {
const { canvas } = this.game;
const width =
window.innerWidth > 0 ? window.innerWidth : window.screen.width;
Expand All @@ -26,7 +31,7 @@ export default class Boot extends Scene {
canvas.style.width = height * ratio + 'px';
canvas.style.height = height + 'px';
}
}
};

preload() {
const { load } = this;
Expand Down

0 comments on commit bf23a18

Please sign in to comment.