Skip to content

Commit

Permalink
resize display if viewport changes
Browse files Browse the repository at this point in the history
  • Loading branch information
oberhamsi committed Jun 2, 2014
1 parent d222776 commit 03ccc0b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/gamejs/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ exports.hasPointerLock = function() {
document.mozFullScreenElement);
};

function onResize(event) {
var canvas = getCanvas();
SURFACE._canvas.width = canvas.clientWidth;
SURFACE._canvas.height = canvas.clientHeight;
}

/**
* Create the master Canvas plane.
* @ignore
Expand All @@ -144,6 +150,8 @@ exports.init = function() {
if ($loader) {
$loader.style.display = "none";
}
// hook into resize
window.addEventListener("resize", onResize, false);
return;
};

Expand Down

0 comments on commit 03ccc0b

Please sign in to comment.