Skip to content

Commit

Permalink
Added resizeToFill attribute to System
Browse files Browse the repository at this point in the history
  • Loading branch information
Eemeli Kelokorpi committed May 22, 2014
1 parent 65ae80f commit abbe65b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/engine/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ game.System = game.Class.extend({
if (!width) width = (game.System.orientation === game.System.PORTRAIT ? 768 : 1024);
if (!height) height = (game.System.orientation === game.System.PORTRAIT ? 927 : 672);

if (game.System.resizeToFill && game.device.mobile) {
var innerWidth = window.innerWidth;
var innerHeight = window.innerHeight;

if (game.device.iPad && innerHeight === 671) innerHeight = 672; // iOS 7 bugfix
if (game.device.iPhone && innerHeight === 320) innerHeight = 319; // iOS 7 bugfix

if (innerWidth / innerHeight !== width / height) {
if (game.System.orientation === game.System.LANDSCAPE) width = height * (innerWidth / innerHeight);
else height = width * (innerHeight / innerWidth);
}
}

if (game.System.hires) {
if (typeof game.System.hiresWidth === 'number' && typeof game.System.hiresHeight === 'number') {
if (window.innerWidth >= game.System.hiresWidth && window.innerHeight >= game.System.hiresHeight) {
Expand Down Expand Up @@ -623,4 +636,11 @@ game.System.transparent = false;
**/
game.System.antialias = false;

/**
Resize canvas to fill screen on mobile.
@attribute {Boolean} resizeToFill
@default false
**/
game.System.resizeToFill = false;

});

0 comments on commit abbe65b

Please sign in to comment.