phaser/src/core/ScaleManager.js

2373 lines
74 KiB
JavaScript
Raw Normal View History

2013-10-01 12:54:29 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2015-02-25 03:36:23 +00:00
* @copyright 2015 Photon Storm Ltd.
2013-10-01 12:54:29 +00:00
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* @classdesc
* The ScaleManager object handles the the scaling, resizing, and alignment of the
* Game size and the game Display canvas.
2014-10-31 10:29:54 +00:00
*
* The Game size is the logical size of the game; the Display canvas has size as an HTML element.
*
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* The calculations of these are heavily influenced by the bounding Parent size which is the computed
2015-01-06 12:58:19 +00:00
* dimensions of the Display canvas's Parent container/element - the _effective CSS rules of the
* canvas's Parent element play an important role_ in the operation of the ScaleManager.
*
* The Display canvas - or Game size, depending {@link #scaleMode} - is updated to best utilize the Parent size.
* When in Fullscreen mode or with {@link #parentIsWindow} the Parent size is that of the visual viewport (see {@link Phaser.ScaleManager#getParentBounds getParentBounds}).
*
* Parent and Display canvas containment guidelines:
*
* - Style the Parent element (of the game canvas) to control the Parent size and
* thus the Display canvas's size and layout.
*
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* - The Parent element's CSS styles should _effectively_ apply maximum (and minimum) bounding behavior.
*
* - The Parent element should _not_ apply a padding as this is not accounted for.
* If a padding is required apply it to the Parent's parent or apply a margin to the Parent.
2015-01-05 11:57:46 +00:00
* If you need to add a border, margin or any other CSS around your game container, then use a parent element and
* apply the CSS to this instead, otherwise you'll be constantly resizing the shape of the game container.
*
* - The Display canvas layout CSS styles (i.e. margins, size) should not be altered/specified as
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* they may be updated by the ScaleManager.
*
* @description
* Create a new ScaleManager object - this is done automatically by {@link Phaser.Game}
*
* The `width` and `height` constructor parameters can either be a number which represents pixels or a string that represents a percentage: e.g. `800` (for 800 pixels) or `"80%"` for 80%.
*
* @class
2013-10-01 12:54:29 +00:00
* @param {Phaser.Game} game - A reference to the currently running game.
2014-10-31 10:29:54 +00:00
* @param {number|string} width - The width of the game. See above.
* @param {number|string} height - The height of the game. See above.
2013-10-01 12:54:29 +00:00
*/
Phaser.ScaleManager = function (game, width, height) {
/**
2014-10-31 10:29:54 +00:00
* A reference to the currently running game.
* @property {Phaser.Game} game
* @protected
* @readonly
*/
this.game = game;
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
/**
* Provides access to some cross-device DOM functions.
* @property {Phaser.DOM} dom
* @protected
* @readonly
*/
this.dom = Phaser.DOM;
2014-09-05 05:02:25 +00:00
/**
2014-10-31 10:29:54 +00:00
* _EXPERIMENTAL:_ A responsive grid on which you can align game objects.
* @property {Phaser.FlexGrid} grid
2014-10-31 10:29:54 +00:00
* @public
2014-09-05 05:02:25 +00:00
*/
this.grid = null;
/**
* Target width (in pixels) of the Display canvas.
* @property {number} width
* @readonly
*/
this.width = 0;
/**
* Target height (in pixels) of the Display canvas.
* @property {number} height
* @readonly
*/
this.height = 0;
/**
2014-10-31 10:29:54 +00:00
* Minimum width the canvas should be scaled to (in pixels).
* Change with {@link #setMinMax}.
* @property {?number} minWidth
2014-10-31 10:29:54 +00:00
* @readonly
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* @protected
*/
this.minWidth = null;
/**
2014-10-31 10:29:54 +00:00
* Maximum width the canvas should be scaled to (in pixels).
* If null it will scale to whatever width the browser can handle.
* Change with {@link #setMinMax}.
* @property {?number} maxWidth
2014-10-31 10:29:54 +00:00
* @readonly
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* @protected
*/
this.maxWidth = null;
/**
2014-10-31 10:29:54 +00:00
* Minimum height the canvas should be scaled to (in pixels).
* Change with {@link #setMinMax}.
* @property {?number} minHeight
2014-10-31 10:29:54 +00:00
* @readonly
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* @protected
*/
this.minHeight = null;
/**
2014-10-31 10:29:54 +00:00
* Maximum height the canvas should be scaled to (in pixels).
* If null it will scale to whatever height the browser can handle.
* Change with {@link #setMinMax}.
* @property {?number} maxHeight
2014-10-31 10:29:54 +00:00
* @readonly
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* @protected
*/
this.maxHeight = null;
/**
* The offset coordinates of the Display canvas from the top-left of the browser window.
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
* The is used internally by Phaser.Pointer (for Input) and possibly other types.
2014-10-31 10:29:54 +00:00
* @property {Phaser.Point} offset
* @readonly
* @protected
*/
this.offset = new Phaser.Point();
/**
2014-10-31 10:29:54 +00:00
* If true, the game should only run in a landscape orientation.
* Change with {@link #forceOrientation}.
2014-10-31 10:29:54 +00:00
* @property {boolean} forceLandscape
* @readonly
2013-10-01 12:54:29 +00:00
* @default
* @protected
*/
this.forceLandscape = false;
/**
2014-10-31 10:29:54 +00:00
* If true, the game should only run in a portrait
* Change with {@link #forceOrientation}.
2014-10-31 10:29:54 +00:00
* @property {boolean} forcePortrait
* @readonly
2013-10-01 12:54:29 +00:00
* @default
* @protected
*/
this.forcePortrait = false;
/**
* True if {@link #forceLandscape} or {@link #forcePortrait} are set and do not agree with the browser orientation.
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
*
* This value is not updated immediately.
*
* @property {boolean} incorrectOrientation
2014-10-31 10:29:54 +00:00
* @readonly
* @protected
*/
this.incorrectOrientation = false;
/**
* See {@link #pageAlignHorizontally}.
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* @property {boolean} _pageAlignHorizontally
* @private
*/
this._pageAlignHorizontally = false;
/**
* See {@link #pageAlignVertically}.
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* @property {boolean} _pageAlignVertically
* @private
*/
this._pageAlignVertically = false;
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
/**
* This signal is dispatched when the orientation changes _or_ the validity of the current orientation changes.
*
* The signal is supplied with the following arguments:
* - `scale` - the ScaleManager object
* - `prevOrientation`, a string - The previous orientation as per {@link Phaser.ScaleManager#screenOrientation screenOrientation}.
* - `wasIncorrect`, a boolean - True if the previous orientation was last determined to be incorrect.
*
* Access the current orientation and validity with `scale.screenOrientation` and `scale.incorrectOrientation`.
* Thus the following tests can be done:
*
* // The orientation itself changed:
* scale.screenOrientation !== prevOrientation
* // The orientation just became incorrect:
* scale.incorrectOrientation && !wasIncorrect
*
* It is possible that this signal is triggered after {@link #forceOrientation} so the orientation
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* correctness changes even if the orientation itself does not change.
*
* This is signaled from `preUpdate` (or `pauseUpdate`) _even when_ the game is paused.
*
* @property {Phaser.Signal} onOrientationChange
* @public
*/
this.onOrientationChange = new Phaser.Signal();
/**
* This signal is dispatched when the browser enters an incorrect orientation, as defined by {@link #forceOrientation}.
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
*
* This is signaled from `preUpdate` (or `pauseUpdate`) _even when_ the game is paused.
*
2014-10-31 10:29:54 +00:00
* @property {Phaser.Signal} enterIncorrectOrientation
* @public
*/
this.enterIncorrectOrientation = new Phaser.Signal();
/**
* This signal is dispatched when the browser leaves an incorrect orientation, as defined by {@link #forceOrientation}.
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
*
* This is signaled from `preUpdate` (or `pauseUpdate`) _even when_ the game is paused.
*
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* @property {Phaser.Signal} leaveIncorrectOrientation
2014-10-31 10:29:54 +00:00
* @public
*/
this.leaveIncorrectOrientation = new Phaser.Signal();
/**
* If specified, this is the DOM element on which the Fullscreen API enter request will be invoked.
* The target element must have the correct CSS styling and contain the Display canvas.
*
2014-12-03 03:18:52 +00:00
* The elements style will be modified (ie. the width and height might be set to 100%)
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* but it will not be added to, removed from, or repositioned within the DOM.
* An attempt is made to restore relevant style changes when fullscreen mode is left.
*
* For pre-2.2.0 behavior set `game.scale.fullScreenTarget = game.canvas`.
*
* @property {?DOMElement} fullScreenTarget
* @default
*/
this.fullScreenTarget = null;
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
/**
* The fullscreen target, as created by {@link #createFullScreenTarget}.
* This is not set if {@link #fullScreenTarget} is used and is cleared when fullscreen mode ends.
* @property {?DOMElement} _createdFullScreenTarget
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* @private
*/
this._createdFullScreenTarget = null;
/**
* This signal is dispatched when fullscreen mode is ready to be initialized but
* before the fullscreen request.
*
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* The signal is passed two arguments: `scale` (the ScaleManager), and an object in the form `{targetElement: DOMElement}`.
*
* The `targetElement` is the {@link #fullScreenTarget} element,
* if such is assigned, or a new element created by {@link #createFullScreenTarget}.
*
* Custom CSS styling or resets can be applied to `targetElement` as required.
*
* If `targetElement` is _not_ the same element as {@link #fullScreenTarget}:
* - After initialization the Display canvas is moved onto the `targetElement` for
* the duration of the fullscreen mode, and restored to it's original DOM location when fullscreen is exited.
2015-01-06 12:58:19 +00:00
* - The `targetElement` is moved/re-parented within the DOM and may have its CSS styles updated.
*
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* The behavior of a pre-assigned target element is covered in {@link Phaser.ScaleManager#fullScreenTarget fullScreenTarget}.
*
* @property {Phaser.Signal} onFullScreenInit
* @public
*/
this.onFullScreenInit = new Phaser.Signal();
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
/**
* This signal is dispatched when the browser enters or leaves fullscreen mode, if supported.
*
* The signal is supplied with a single argument: `scale` (the ScaleManager). Use `scale.isFullScreen` to determine
* if currently running in Fullscreen mode.
*
* @property {Phaser.Signal} onFullScreenChange
* @public
*/
this.onFullScreenChange = new Phaser.Signal();
/**
* This signal is dispatched when the browser fails to enter fullscreen mode;
* or if the device does not support fullscreen mode and `startFullScreen` is invoked.
*
* The signal is supplied with a single argument: `scale` (the ScaleManager).
*
* @property {Phaser.Signal} onFullScreenError
* @public
*/
this.onFullScreenError = new Phaser.Signal();
/**
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
* The _last known_ orientation of the screen, as defined in the Window Screen Web API.
* See {@link Phaser.DOM.getScreenOrientation} for possible values.
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
*
* @property {string} screenOrientation
2014-10-31 10:29:54 +00:00
* @readonly
* @public
*/
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
this.screenOrientation = this.dom.getScreenOrientation();
2013-10-01 12:54:29 +00:00
/**
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
* The _current_ scale factor based on the game dimensions vs. the scaled dimensions.
2014-10-31 10:29:54 +00:00
* @property {Phaser.Point} scaleFactor
* @readonly
2013-10-01 12:54:29 +00:00
*/
this.scaleFactor = new Phaser.Point(1, 1);
2013-10-01 12:54:29 +00:00
/**
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
* The _current_ inversed scale factor. The displayed dimensions divided by the game dimensions.
2014-10-31 10:29:54 +00:00
* @property {Phaser.Point} scaleFactorInversed
* @readonly
* @protected
*/
this.scaleFactorInversed = new Phaser.Point(1, 1);
/**
* The Display canvas is aligned by adjusting the margins; the last margins are stored here.
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
*
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
* @property {Bounds-like} margin
* @readonly
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* @protected
*/
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
this.margin = {left: 0, top: 0, right: 0, bottom: 0, x: 0, y: 0};
/**
2014-10-31 10:29:54 +00:00
* The bounds of the scaled game. The x/y will match the offset of the canvas element and the width/height the scaled width and height.
* @property {Phaser.Rectangle} bounds
* @readonly
*/
this.bounds = new Phaser.Rectangle();
2013-10-01 12:54:29 +00:00
/**
* The aspect ratio of the scaled Display canvas.
2014-10-31 10:29:54 +00:00
* @property {number} aspectRatio
* @readonly
2013-10-01 12:54:29 +00:00
*/
this.aspectRatio = 0;
/**
2014-10-31 10:29:54 +00:00
* The aspect ratio of the original game dimensions.
* @property {number} sourceAspectRatio
* @readonly
*/
this.sourceAspectRatio = 0;
/**
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
* The native browser events from Fullscreen API changes.
2014-10-31 10:29:54 +00:00
* @property {any} event
* @readonly
* @private
*/
this.event = null;
/**
* The edges on which to constrain the game Display/canvas in _addition_ to the restrictions of the parent container.
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
*
* The properties are strings and can be '', 'visual', 'layout', or 'layout-soft'.
* - If 'visual', the edge will be constrained to the Window / displayed screen area
* - If 'layout', the edge will be constrained to the CSS Layout bounds
* - An invalid value is treated as 'visual'
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
*
* @member
* @property {string} bottom
* @property {string} right
* @default
*/
2014-11-08 14:04:17 +00:00
this.windowConstraints = {
right: 'layout',
bottom: ''
2014-11-08 14:04:17 +00:00
};
/**
* Various compatibility settings.
* A value of "(auto)" indicates the setting is configured based on device and runtime information.
*
2015-01-06 12:58:19 +00:00
* A {@link #refresh} may need to be performed after making changes.
*
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
* @protected
*
* @property {boolean} [supportsFullscreen=(auto)] - True only if fullscreen support will be used. (Changing to fullscreen still might not work.)
*
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
* @property {boolean} [orientationFallback=(auto)] - See {@link Phaser.DOM.getScreenOrientation}.
*
* @property {boolean} [noMargins=false] - If true then the Display canvas's margins will not be updated anymore: existing margins must be manually cleared. Disabling margins prevents automatic canvas alignment/centering, possibly in fullscreen.
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
*
* @property {?Phaser.Point} [scrollTo=(auto)] - If specified the window will be scrolled to this position on every refresh.
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
*
2015-01-06 12:58:19 +00:00
* @property {boolean} [forceMinimumDocumentHeight=false] - If enabled the document elements minimum height is explicitly set on updates.
* The height set varies by device and may either be the height of the window or the viewport.
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
*
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* @property {boolean} [canExpandParent=true] - If enabled then SHOW_ALL and USER_SCALE modes can try and expand the parent element. It may be necessary for the parent element to impose CSS width/height restrictions.
*
* @property {string} [clickTrampoline=(auto)] - On certain browsers (eg. IE) FullScreen events need to be triggered via 'click' events.
* A value of 'when-not-mouse' uses a click trampoline when a pointer that is not the primary mouse is used.
* Any other string value (including the empty string) prevents using click trampolines.
* For more details on click trampolines see {@link Phaser.Pointer#addClickTrampoline}.
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
*/
this.compatibility = {
supportsFullScreen: false,
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
orientationFallback: null,
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
noMargins: false,
scrollTo: null,
forceMinimumDocumentHeight: false,
canExpandParent: true,
clickTrampoline: ''
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
};
/**
* Scale mode to be used when not in fullscreen.
* @property {number} _scaleMode
* @private
*/
this._scaleMode = Phaser.ScaleManager.NO_SCALE;
/*
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
* Scale mode to be used in fullscreen.
* @property {number} _fullScreenScaleMode
* @private
*/
this._fullScreenScaleMode = Phaser.ScaleManager.NO_SCALE;
/**
2015-01-06 12:58:19 +00:00
* If the parent container of the Game canvas is the browser window itself (i.e. document.body),
* rather than another div, this should set to `true`.
*
* The {@link #parentNode} property is generally ignored while this is in effect.
*
* @property {boolean} parentIsWindow
*/
this.parentIsWindow = false;
/**
* The _original_ DOM element for the parent of the Display canvas.
* This may be different in fullscreen - see {@link #createFullScreenTarget}.
*
* This should only be changed after moving the Game canvas to a different DOM parent.
*
* @property {?DOMElement} parentNode
*/
this.parentNode = null;
/**
2014-10-31 10:29:54 +00:00
* The scale of the game in relation to its parent container.
* @property {Phaser.Point} parentScaleFactor
* @readonly
*/
this.parentScaleFactor = new Phaser.Point(1, 1);
/**
* The maximum time (in ms) between dimension update checks for the Canvas's parent element (or window).
* Update checks normally happen quicker in response to other events.
*
* @property {integer} trackParentInterval
* @default
* @protected
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* @see {@link Phaser.ScaleManager#refresh refresh}
*/
2014-09-01 07:19:43 +00:00
this.trackParentInterval = 2000;
2014-12-01 21:05:53 +00:00
/**
* This signal is dispatched when the size of the Display canvas changes _or_ the size of the Game changes.
* When invoked this is done _after_ the Canvas size/position have been updated.
*
* This signal is _only_ called when a change occurs and a reflow may be required.
* For example, if the canvas does not change sizes because of CSS settings (such as min-width)
* then this signal will _not_ be triggered.
*
* Use this to handle responsive game layout options.
*
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
* This is signaled from `preUpdate` (or `pauseUpdate`) _even when_ the game is paused.
*
* @property {Phaser.Signal} onSizeChange
* @todo Formalize the arguments, if any, supplied to this signal.
*/
this.onSizeChange = new Phaser.Signal();
/**
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* The callback that will be called each the parent container resizes.
2014-10-31 10:29:54 +00:00
* @property {function} onResize
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* @private
*/
this.onResize = null;
/**
* The context in which the {@link #onResize} callback will be called.
2014-10-31 10:29:54 +00:00
* @property {object} onResizeContext
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* @private
*/
this.onResizeContext = null;
/**
* @property {integer} _pendingScaleMode - Used to retain the scale mode if set from config before Boot.
* @private
*/
this._pendingScaleMode = null;
/**
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
* Information saved when fullscreen mode is started.
* @property {?object} _fullScreenRestore
* @private
*/
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this._fullScreenRestore = null;
/**
* The _actual_ game dimensions, as initially set or set by {@link #setGameSize}.
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* @property {Phaser.Rectangle} _gameSize
* @private
*/
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this._gameSize = new Phaser.Rectangle();
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
/**
* The user-supplied scale factor, used with the USER_SCALE scaling mode.
* @property {Phaser.Point} _userScaleFactor
* @private
*/
this._userScaleFactor = new Phaser.Point(1, 1);
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
/**
* The user-supplied scale trim, used with the USER_SCALE scaling mode.
* @property {Phaser.Point} _userScaleTrim
* @private
*/
this._userScaleTrim = new Phaser.Point(0, 0);
/**
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* The last time the bounds were checked in `preUpdate`.
* @property {number} _lastUpdate
2014-10-31 10:29:54 +00:00
* @private
*/
this._lastUpdate = 0;
/**
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* Size checks updates are delayed according to the throttle.
* The throttle increases to `trackParentInterval` over time and is used to more
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
* rapidly detect changes in certain browsers (eg. IE) while providing back-off safety.
* @property {integer} _updateThrottle
* @private
*/
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
this._updateThrottle = 0;
/**
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
* The minimum throttle allowed until it has slowed down sufficiently.
* @property {integer} _updateThrottleReset
* @private
*/
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
this._updateThrottleReset = 100;
/**
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* The cached result of the parent (possibly window) bounds; used to invalidate sizing.
* @property {Phaser.Rectangle} _parentBounds
* @private
*/
this._parentBounds = new Phaser.Rectangle();
/**
* Temporary bounds used for internal work to cut down on new objects created.
* @property {Phaser.Rectangle} _parentBounds
* @private
*/
this._tempBounds = new Phaser.Rectangle();
/**
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
* The Canvas size at which the last onSizeChange signal was triggered.
* @property {Phaser.Rectangle} _lastReportedCanvasSize
* @private
*/
this._lastReportedCanvasSize = new Phaser.Rectangle();
/**
* The Game size at which the last onSizeChange signal was triggered.
* @property {Phaser.Rectangle} _lastReportedGameSize
* @private
*/
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
this._lastReportedGameSize = new Phaser.Rectangle();
/**
* @property {boolean} _booted - ScaleManager booted state.
* @private
*/
this._booted = false;
if (game.config)
{
this.parseConfig(game.config);
}
2014-09-01 07:19:43 +00:00
this.setupScale(width, height);
};
2013-10-03 00:21:08 +00:00
/**
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* A scale mode that stretches content to fill all available space - see {@link Phaser.ScaleManager#scaleMode scaleMode}.
*
2013-10-03 00:21:08 +00:00
* @constant
* @type {integer}
2013-10-03 00:21:08 +00:00
*/
Phaser.ScaleManager.EXACT_FIT = 0;
2013-10-03 00:21:08 +00:00
/**
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* A scale mode that prevents any scaling - see {@link Phaser.ScaleManager#scaleMode scaleMode}.
*
2013-10-03 00:21:08 +00:00
* @constant
* @type {integer}
2013-10-03 00:21:08 +00:00
*/
Phaser.ScaleManager.NO_SCALE = 1;
2013-10-03 00:21:08 +00:00
/**
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* A scale mode that shows the entire game while maintaining proportions - see {@link Phaser.ScaleManager#scaleMode scaleMode}.
*
2013-10-03 00:21:08 +00:00
* @constant
* @type {integer}
2013-10-03 00:21:08 +00:00
*/
Phaser.ScaleManager.SHOW_ALL = 2;
/**
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* A scale mode that causes the Game size to change - see {@link Phaser.ScaleManager#scaleMode scaleMode}.
*
* @constant
* @type {integer}
*/
Phaser.ScaleManager.RESIZE = 3;
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
/**
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* A scale mode that allows a custom scale factor - see {@link Phaser.ScaleManager#scaleMode scaleMode}.
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
*
* @constant
* @type {integer}
*/
Phaser.ScaleManager.USER_SCALE = 4;
Phaser.ScaleManager.prototype = {
2013-10-03 00:21:08 +00:00
2014-11-04 23:56:23 +00:00
/**
* Start the ScaleManager.
2014-11-04 23:56:23 +00:00
*
* @method Phaser.ScaleManager#boot
* @protected
*/
boot: function () {
// Configure device-dependent compatibility
var compat = this.compatibility;
compat.supportsFullScreen = this.game.device.fullscreen && !this.game.device.cocoonJS;
// We can't do anything about the status bars in iPads, web apps or desktops
if (!this.game.device.iPad && !this.game.device.webApp && !this.game.device.desktop)
{
if (this.game.device.android && !this.game.device.chrome)
{
compat.scrollTo = new Phaser.Point(0, 1);
}
else
{
compat.scrollTo = new Phaser.Point(0, 0);
}
}
2014-11-04 23:56:23 +00:00
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
if (this.game.device.desktop)
{
compat.orientationFallback = 'screen';
compat.clickTrampoline = 'when-not-mouse';
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
}
else
{
compat.orientationFallback = '';
compat.clickTrampoline = '';
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
}
// Configure event listeners
2014-11-04 23:56:23 +00:00
var _this = this;
this._orientationChange = function(event) {
return _this.orientationChange(event);
};
this._windowResize = function(event) {
return _this.windowResize(event);
};
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
// This does not appear to be on the standards track
2014-11-04 23:56:23 +00:00
window.addEventListener('orientationchange', this._orientationChange, false);
window.addEventListener('resize', this._windowResize, false);
if (this.compatibility.supportsFullScreen)
2014-11-04 23:56:23 +00:00
{
this._fullScreenChange = function(event) {
return _this.fullScreenChange(event);
};
this._fullScreenError = function(event) {
return _this.fullScreenError(event);
};
document.addEventListener('webkitfullscreenchange', this._fullScreenChange, false);
document.addEventListener('mozfullscreenchange', this._fullScreenChange, false);
document.addEventListener('MSFullscreenChange', this._fullScreenChange, false);
document.addEventListener('fullscreenchange', this._fullScreenChange, false);
document.addEventListener('webkitfullscreenerror', this._fullScreenError, false);
document.addEventListener('mozfullscreenerror', this._fullScreenError, false);
document.addEventListener('MSFullscreenError', this._fullScreenError, false);
document.addEventListener('fullscreenerror', this._fullScreenError, false);
}
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
this.game.onResume.add(this._gameResumed, this);
// Initialize core bounds
2014-11-04 23:56:23 +00:00
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
this.dom.getOffset(this.game.canvas, this.offset);
2014-11-04 23:56:23 +00:00
this.bounds.setTo(this.offset.x, this.offset.y, this.width, this.height);
this.setGameSize(this.game.width, this.game.height);
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
// Don't use updateOrientationState so events are not fired
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
this.screenOrientation = this.dom.getScreenOrientation(this.compatibility.orientationFallback);
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
if (Phaser.FlexGrid)
{
this.grid = new Phaser.FlexGrid(this, this.width, this.height);
}
2015-01-06 12:58:19 +00:00
this._booted = true;
if (this._pendingScaleMode)
{
this.scaleMode = this._pendingScaleMode;
this._pendingScaleMode = null;
}
2014-11-04 23:56:23 +00:00
},
/**
2014-10-31 10:29:54 +00:00
* Load configuration settings.
*
* @method Phaser.ScaleManager#parseConfig
2014-10-31 10:29:54 +00:00
* @protected
* @param {object} config - The game configuration object.
*/
parseConfig: function (config) {
if (config['scaleMode'])
{
if (this._booted)
{
this.scaleMode = config['scaleMode'];
}
else
{
this._pendingScaleMode = config['scaleMode'];
}
}
if (config['fullScreenScaleMode'])
{
this.fullScreenScaleMode = config['fullScreenScaleMode'];
}
if (config['fullScreenTarget'])
{
this.fullScreenTarget = config['fullScreenTarget'];
}
},
/**
* Calculates and sets the game dimensions based on the given width and height.
*
* This should _not_ be called when in fullscreen mode.
*
2014-09-01 07:19:43 +00:00
* @method Phaser.ScaleManager#setupScale
* @protected
* @param {number|string} width - The width of the game.
* @param {number|string} height - The height of the game.
*/
2014-09-01 07:19:43 +00:00
setupScale: function (width, height) {
var target;
var rect = new Phaser.Rectangle();
if (this.game.parent !== '')
{
if (typeof this.game.parent === 'string')
{
// hopefully an element ID
target = document.getElementById(this.game.parent);
}
else if (this.game.parent && this.game.parent.nodeType === 1)
{
// quick test for a HTMLelement
target = this.game.parent;
}
}
// Fallback, covers an invalid ID and a non HTMLelement object
if (!target)
{
// Use the full window
this.parentNode = null;
this.parentIsWindow = true;
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
rect.width = this.dom.visualBounds.width;
2014-11-18 07:56:30 +00:00
rect.height = this.dom.visualBounds.height;
this.offset.set(0, 0);
}
else
{
this.parentNode = target;
this.parentIsWindow = false;
this.getParentBounds(this._parentBounds);
2014-09-01 07:19:43 +00:00
rect.width = this._parentBounds.width;
rect.height = this._parentBounds.height;
this.offset.set(this._parentBounds.x, this._parentBounds.y);
}
var newWidth = 0;
var newHeight = 0;
if (typeof width === 'number')
{
newWidth = width;
}
else
{
// Percentage based
this.parentScaleFactor.x = parseInt(width, 10) / 100;
newWidth = rect.width * this.parentScaleFactor.x;
}
if (typeof height === 'number')
{
newHeight = height;
}
else
{
// Percentage based
this.parentScaleFactor.y = parseInt(height, 10) / 100;
newHeight = rect.height * this.parentScaleFactor.y;
}
this._gameSize.setTo(0, 0, newWidth, newHeight);
this.updateDimensions(newWidth, newHeight, false);
},
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
/**
* Invoked when the game is resumed.
2014-11-25 21:13:13 +00:00
*
* @method Phaser.ScaleManager#_gameResumed
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
* @private
*/
2014-11-25 21:13:13 +00:00
_gameResumed: function () {
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
this.queueUpdate(true);
},
/**
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
* Set the actual Game size.
* Use this instead of directly changing `game.width` or `game.height`.
*
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
* The actual physical display (Canvas element size) depends on various settings including
* - Scale mode
* - Scaling factor
* - Size of Canvas's parent element or CSS rules such as min-height/max-height;
* - The size of the Window
*
* @method Phaser.ScaleManager#setGameSize
* @public
* @param {integer} width - _Game width_, in pixels.
* @param {integer} height - _Game height_, in pixels.
*/
setGameSize: function (width, height) {
this._gameSize.setTo(0, 0, width, height);
if (this.currentScaleMode !== Phaser.ScaleManager.RESIZE)
{
this.updateDimensions(width, height, true);
}
this.queueUpdate(true);
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
2014-09-01 07:19:43 +00:00
},
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
/**
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* Set a User scaling factor used in the USER_SCALE scaling mode.
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
*
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* The target canvas size is computed by:
*
* canvas.width = (game.width * hScale) - hTrim
* canvas.height = (game.height * vScale) - vTrim
*
* This method can be used in the {@link Phaser.ScaleManager#setResizeCallback resize callback}.
*
* @method Phaser.ScaleManager#setUserScale
* @param {number} hScale - Horizontal scaling factor.
* @param {numer} vScale - Vertical scaling factor.
* @param {integer} [hTrim=0] - Horizontal trim, applied after scaling.
* @param {integer} [vTrim=0] - Vertical trim, applied after scaling.
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
*/
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
setUserScale: function (hScale, vScale, hTrim, vTrim) {
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
this._userScaleFactor.setTo(hScale, vScale);
this._userScaleTrim.setTo(hTrim | 0, vTrim | 0);
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
this.queueUpdate(true);
},
/**
2014-12-03 03:18:52 +00:00
* Sets the callback that will be invoked before sizing calculations.
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
*
* This is the appropriate place to call {@link #setUserScale} if needing custom dynamic scaling.
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
*
* The callback is supplied with two arguments `scale` and `parentBounds` where `scale` is the ScaleManager
* and `parentBounds`, a Phaser.Rectangle, is the size of the Parent element.
*
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
* This callback
* - May be invoked even though the parent container or canvas sizes have not changed
* - Unlike {@link #onSizeChange}, it runs _before_ the canvas is guaranteed to be updated
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* - Will be invoked from `preUpdate`, _even when_ the game is paused
*
* See {@link #onSizeChange} for a better way of reacting to layout updates.
*
* @method Phaser.ScaleManager#setResizeCallback
* @public
* @param {function} callback - The callback that will be called each time a window.resize event happens or if set, the parent container resizes.
* @param {object} context - The context in which the callback will be called.
*/
setResizeCallback: function (callback, context) {
this.onResize = callback;
this.onResizeContext = context;
},
/**
* Signals a resize - IF the canvas or Game size differs from the last signal.
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
*
* This also triggers updates on {@link #grid} (FlexGrid) and, if in a RESIZE mode, `game.state` (StateManager).
*
2015-01-06 12:58:19 +00:00
* @method Phaser.ScaleManager#signalSizeChange
* @private
*/
signalSizeChange: function () {
if (!Phaser.Rectangle.sameDimensions(this, this._lastReportedCanvasSize) ||
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
!Phaser.Rectangle.sameDimensions(this.game, this._lastReportedGameSize))
{
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
var width = this.width;
var height = this.height;
this._lastReportedCanvasSize.setTo(0, 0, width, height);
this._lastReportedGameSize.setTo(0, 0, this.game.width, this.game.height);
if (this.grid)
{
this.grid.onResize(width, height);
}
this.onSizeChange.dispatch(this, width, height);
// Per StateManager#onResizeCallback, it only occurs when in RESIZE mode.
if (this.currentScaleMode === Phaser.ScaleManager.RESIZE)
{
this.game.state.resize(width, height);
2014-11-11 13:59:56 +00:00
this.game.load.resize(width, height);
}
}
},
/**
* Set the min and max dimensions for the Display canvas.
*
* _Note:_ The min/max dimensions are only applied in some cases
* - When the device is not in an incorrect orientation; or
* - The scale mode is EXACT_FIT when not in fullscreen
*
2014-11-04 23:56:23 +00:00
* @method Phaser.ScaleManager#setMinMax
* @public
* @param {number} minWidth - The minimum width the game is allowed to scale down to.
* @param {number} minHeight - The minimum height the game is allowed to scale down to.
* @param {number} [maxWidth] - The maximum width the game is allowed to scale up to; only changed if specified.
* @param {number} [maxHeight] - The maximum height the game is allowed to scale up to; only changed if specified.
* @todo These values are only sometimes honored.
*/
setMinMax: function (minWidth, minHeight, maxWidth, maxHeight) {
this.minWidth = minWidth;
this.minHeight = minHeight;
if (typeof maxWidth !== 'undefined')
{
this.maxWidth = maxWidth;
}
if (typeof maxHeight !== 'undefined')
{
this.maxHeight = maxHeight;
}
},
2013-10-01 12:54:29 +00:00
/**
* The ScaleManager.preUpdate is called automatically by the core Game loop.
*
* @method Phaser.ScaleManager#preUpdate
* @protected
2013-10-01 12:54:29 +00:00
*/
preUpdate: function () {
if (this.game.time.time < (this._lastUpdate + this._updateThrottle))
{
return;
}
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
var prevThrottle = this._updateThrottle;
this._updateThrottleReset = prevThrottle >= 400 ? 0 : 100;
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
this.dom.getOffset(this.game.canvas, this.offset);
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
var prevWidth = this._parentBounds.width;
var prevHeight = this._parentBounds.height;
var bounds = this.getParentBounds(this._parentBounds);
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
var boundsChanged = bounds.width !== prevWidth || bounds.height !== prevHeight;
// Always invalidate on a newly detected orientation change
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
var orientationChanged = this.updateOrientationState();
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
if (boundsChanged || orientationChanged)
{
if (this.onResize)
{
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
this.onResize.call(this.onResizeContext, this, bounds);
}
this.updateLayout();
this.signalSizeChange();
}
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
// Next throttle, eg. 25, 50, 100, 200..
var throttle = this._updateThrottle * 2;
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
// Don't let an update be too eager about resetting the throttle.
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
if (this._updateThrottle < prevThrottle)
{
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
throttle = Math.min(prevThrottle, this._updateThrottleReset);
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
}
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
this._updateThrottle = Phaser.Math.clamp(throttle, 25, this.trackParentInterval);
this._lastUpdate = this.game.time.time;
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
},
2014-11-25 21:13:13 +00:00
/**
* Update method while paused.
*
* @method Phaser.ScaleManager#pauseUpdate
* @private
*/
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
pauseUpdate: function () {
this.preUpdate();
// Updates at slowest.
this._updateThrottle = this.trackParentInterval;
},
2013-10-01 12:54:29 +00:00
/**
* Update the dimensions taking the parent scaling factor into account.
*
* @method Phaser.ScaleManager#updateDimensions
* @private
* @param {number} width - The new width of the parent container.
* @param {number} height - The new height of the parent container.
* @param {boolean} resize - True if the renderer should be resized, otherwise false to just update the internal vars.
*/
updateDimensions: function (width, height, resize) {
this.width = width * this.parentScaleFactor.x;
this.height = height * this.parentScaleFactor.y;
this.game.width = this.width;
this.game.height = this.height;
this.sourceAspectRatio = this.width / this.height;
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.updateScalingAndBounds();
if (resize)
{
// Resize the renderer (which in turn resizes the Display canvas!)
this.game.renderer.resize(this.width, this.height);
// The Camera can never be smaller than the Game size
this.game.camera.setSize(this.width, this.height);
// This should only happen if the world is smaller than the new canvas size
this.game.world.resize(this.width, this.height);
}
},
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
/**
* Update relevant scaling values based on the ScaleManager dimension and game dimensions,
* which should already be set. This does not change {@link #sourceAspectRatio}.
2014-11-25 21:13:13 +00:00
*
* @method Phaser.ScaleManager#updateScalingAndBounds
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* @private
*/
updateScalingAndBounds: function () {
this.scaleFactor.x = this.game.width / this.width;
this.scaleFactor.y = this.game.height / this.height;
this.scaleFactorInversed.x = this.width / this.game.width;
this.scaleFactorInversed.y = this.height / this.game.height;
this.aspectRatio = this.width / this.height;
// This can be invoked in boot pre-canvas
if (this.game.canvas)
{
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
this.dom.getOffset(this.game.canvas, this.offset);
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
}
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.bounds.setTo(this.offset.x, this.offset.y, this.width, this.height);
// Can be invoked in boot pre-input
if (this.game.input && this.game.input.scale)
{
this.game.input.scale.setTo(this.scaleFactor.x, this.scaleFactor.y);
}
},
/**
2014-10-31 10:29:54 +00:00
* Force the game to run in only one orientation.
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
*
* This enables generation of incorrect orientation signals and affects resizing but does not otherwise rotate or lock the orientation.
2015-02-11 13:47:58 +00:00
*
* Orientation checks are performed via the Screen Orientation API, if available in browser. This means it will check your monitor
* orientation on desktop, or your device orientation on mobile, rather than comparing actual game dimensions. If you need to check the
* viewport dimensions instead and bypass the Screen Orientation API then set: `ScaleManager.compatibility.orientationFallback = 'viewport'`
*
* @method Phaser.ScaleManager#forceOrientation
* @public
* @param {boolean} forceLandscape - true if the game should run in landscape mode only.
* @param {boolean} [forcePortrait=false] - true if the game should run in portrait mode only.
*/
forceOrientation: function (forceLandscape, forcePortrait) {
if (forcePortrait === undefined) { forcePortrait = false; }
this.forceLandscape = forceLandscape;
this.forcePortrait = forcePortrait;
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
this.queueUpdate(true);
},
2013-10-01 12:54:29 +00:00
/**
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
* Classify the orientation, per `getScreenOrientation`.
2014-11-25 21:13:13 +00:00
*
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
* @method Phaser.ScaleManager#classifyOrientation
* @private
* @param {string} orientation - The orientation string, e.g. 'portrait-primary'.
* @return {?string} The classified orientation: 'portrait', 'landscape`, or null.
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
*/
classifyOrientation: function (orientation) {
if (orientation === 'portrait-primary' || orientation === 'portrait-secondary')
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
{
return 'portrait';
}
else if (orientation === 'landscape-primary' || orientation === 'landscape-secondary')
{
return 'landscape';
}
else
{
return null;
}
},
/**
* Updates the current orientation and dispatches orientation change events.
*
* @method Phaser.ScaleManager#updateOrientationState
* @private
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
* @return {boolean} True if the orientation state changed which means a forced update is likely required.
2013-10-01 12:54:29 +00:00
*/
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
updateOrientationState: function () {
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
var previousOrientation = this.screenOrientation;
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
var previouslyIncorrect = this.incorrectOrientation;
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
this.screenOrientation = this.dom.getScreenOrientation(this.compatibility.orientationFallback);
this.incorrectOrientation = (this.forceLandscape && !this.isLandscape) ||
(this.forcePortrait && !this.isPortrait);
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
var changed = previousOrientation !== this.screenOrientation;
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
var correctnessChanged = previouslyIncorrect !== this.incorrectOrientation;
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
2014-11-25 21:13:13 +00:00
if (correctnessChanged)
{
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
if (this.incorrectOrientation)
{
this.enterIncorrectOrientation.dispatch();
}
else
{
this.leaveIncorrectOrientation.dispatch();
}
}
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
if (changed || correctnessChanged)
{
this.onOrientationChange.dispatch(this, previousOrientation, previouslyIncorrect);
}
return changed || correctnessChanged;
},
2013-10-01 12:54:29 +00:00
/**
* window.orientationchange event handler.
*
* @method Phaser.ScaleManager#orientationChange
* @private
2013-10-03 00:21:08 +00:00
* @param {Event} event - The orientationchange event data.
*/
orientationChange: function (event) {
this.event = event;
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.queueUpdate(true);
},
2013-10-01 12:54:29 +00:00
/**
* window.resize event handler.
*
* @method Phaser.ScaleManager#windowResize
* @private
2013-10-03 00:21:08 +00:00
* @param {Event} event - The resize event data.
*/
windowResize: function (event) {
this.event = event;
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
this.queueUpdate(true);
},
2013-10-01 12:54:29 +00:00
/**
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
* Scroll to the top - in some environments. See `compatibility.scrollTo`.
2014-11-25 21:13:13 +00:00
*
* @method Phaser.ScaleManager#scrollTop
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* @private
*/
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
scrollTop: function () {
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
var scrollTo = this.compatibility.scrollTo;
2014-11-25 21:13:13 +00:00
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
if (scrollTo)
{
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
window.scrollTo(scrollTo.x, scrollTo.y);
}
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
},
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
/**
* The "refresh" methods informs the ScaleManager that a layout refresh is required.
*
* The ScaleManager automatically queues a layout refresh (eg. updates the Game size or Display canvas layout)
* when the browser is resized, the orientation changes, or when there is a detected change
* of the Parent size. Refreshing is also done automatically when public properties,
* such as {@link #scaleMode}, are updated or state-changing methods are invoked.
*
* The "refresh" method _may_ need to be used in a few (rare) situtations when
*
* - a device change event is not correctly detected; or
* - the Parent size changes (and an immediate reflow is desired); or
* - the ScaleManager state is updated by non-standard means; or
* - certain {@link #compatibility} properties are manually changed.
*
* The queued layout refresh is not immediate but will run promptly in an upcoming `preRender`.
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
*
* @method Phaser.ScaleManager#refresh
* @public
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
*/
refresh: function () {
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.scrollTop();
this.queueUpdate(true);
},
2013-10-01 12:54:29 +00:00
/**
* Updates the game / canvas position and size.
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
*
* @method Phaser.ScaleManager#updateLayout
* @private
*/
updateLayout: function () {
var scaleMode = this.currentScaleMode;
if (scaleMode === Phaser.ScaleManager.RESIZE)
{
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.reflowGame();
return;
}
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.scrollTop();
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
if (this.compatibility.forceMinimumDocumentHeight)
{
// (This came from older code, by why is it here?)
// Set minimum height of content to new window height
document.documentElement.style.minHeight = window.innerHeight + 'px';
}
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
if (this.incorrectOrientation)
{
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.setMaximum();
}
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
else
{
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
if (scaleMode === Phaser.ScaleManager.EXACT_FIT)
{
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.setExactFit();
}
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
else if (scaleMode === Phaser.ScaleManager.SHOW_ALL)
{
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
if (!this.isFullScreen && this.boundingParent &&
this.compatibility.canExpandParent)
{
// Try to expand parent out, but choosing maximizing dimensions.
// Then select minimize dimensions which should then honor parent
// maximum bound applications.
this.setShowAll(true);
this.resetCanvas();
this.setShowAll();
}
else
{
this.setShowAll();
}
}
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
else if (scaleMode === Phaser.ScaleManager.NO_SCALE)
{
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.width = this.game.width;
this.height = this.game.height;
}
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
else if (scaleMode === Phaser.ScaleManager.USER_SCALE)
{
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
this.width = (this.game.width * this._userScaleFactor.x) - this._userScaleTrim.x;
this.height = (this.game.height * this._userScaleFactor.y) - this._userScaleTrim.y;
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
}
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
}
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
if (!this.compatibility.canExpandParent &&
(scaleMode === Phaser.ScaleManager.SHOW_ALL || scaleMode === Phaser.ScaleManager.USER_SCALE))
{
var bounds = this.getParentBounds(this._tempBounds);
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
this.width = Math.min(this.width, bounds.width);
this.height = Math.min(this.height, bounds.height);
}
// Always truncate / force to integer
this.width = this.width | 0;
this.height = this.height | 0;
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.reflowCanvas();
},
/**
* Returns the computed Parent size/bounds that the Display canvas is allowed/expected to fill.
2014-10-31 10:29:54 +00:00
*
* If in fullscreen mode or without parent (see {@link #parentIsWindow}),
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* this will be the bounds of the visual viewport itself.
2014-10-31 10:29:54 +00:00
*
* This function takes the {@link #windowConstraints} into consideration - if the parent is partially outside
* the viewport then this function may return a smaller than expected size.
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
*
* Values are rounded to the nearest pixel.
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
*
* @method Phaser.ScaleManager#getParentBounds
* @protected
* @param {Phaser.Rectangle} [target=(new Rectangle)] - The rectangle to update; a new one is created as needed.
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* @return {Phaser.Rectangle} The established parent bounds.
*/
2014-11-08 13:29:12 +00:00
getParentBounds: function (target) {
var bounds = target || new Phaser.Rectangle();
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
var parentNode = this.boundingParent;
var visualBounds = this.dom.visualBounds;
var layoutBounds = this.dom.layoutBounds;
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
if (!parentNode)
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
{
bounds.setTo(0, 0, visualBounds.width, visualBounds.height);
}
else
{
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
// Ref. http://msdn.microsoft.com/en-us/library/hh781509(v=vs.85).aspx for getBoundingClientRect
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
var clientRect = parentNode.getBoundingClientRect();
var parentRect = parentNode.offsetParent.getBoundingClientRect();
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
bounds.setTo(clientRect.left - parentRect.left, clientRect.top - parentRect.top, clientRect.width, clientRect.height);
var wc = this.windowConstraints;
2014-11-25 21:13:13 +00:00
if (wc.right)
{
var windowBounds = wc.right === 'layout' ? layoutBounds : visualBounds;
bounds.right = Math.min(bounds.right, windowBounds.width);
}
2014-11-25 21:13:13 +00:00
if (wc.bottom)
{
var windowBounds = wc.bottom === 'layout' ? layoutBounds : visualBounds;
bounds.bottom = Math.min(bounds.bottom, windowBounds.height);
}
}
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
bounds.setTo(
Math.round(bounds.x), Math.round(bounds.y),
Math.round(bounds.width), Math.round(bounds.height));
return bounds;
},
/**
2014-10-31 10:29:54 +00:00
* Update the canvas position/margins - for alignment within the parent container.
*
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* The canvas margins _must_ be reset/cleared prior to invoking this.
*
* @method Phaser.ScaleManager#alignCanvas
* @private
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* @param {boolean} horizontal - Align horizontally?
* @param {boolean} vertical - Align vertically?
*/
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
alignCanvas: function (horizontal, vertical) {
var parentBounds = this.getParentBounds(this._tempBounds);
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
var canvas = this.game.canvas;
var margin = this.margin;
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
if (horizontal)
{
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
margin.left = margin.right = 0;
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
var canvasBounds = canvas.getBoundingClientRect();
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
if (this.width < parentBounds.width && !this.incorrectOrientation)
{
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
var currentEdge = canvasBounds.left - parentBounds.x;
var targetEdge = (parentBounds.width / 2) - (this.width / 2);
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
targetEdge = Math.max(targetEdge, 0);
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
var offset = targetEdge - currentEdge;
margin.left = Math.round(offset);
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
}
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
canvas.style.marginLeft = margin.left + 'px';
2014-11-25 21:13:13 +00:00
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
if (margin.left !== 0)
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
{
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
margin.right = -(parentBounds.width - canvasBounds.width - margin.left);
canvas.style.marginRight = margin.right + 'px';
}
}
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
if (vertical)
{
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
margin.top = margin.bottom = 0;
var canvasBounds = canvas.getBoundingClientRect();
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
if (this.height < parentBounds.height && !this.incorrectOrientation)
{
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
var currentEdge = canvasBounds.top - parentBounds.y;
var targetEdge = (parentBounds.height / 2) - (this.height / 2);
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
targetEdge = Math.max(targetEdge, 0);
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
var offset = targetEdge - currentEdge;
margin.top = Math.round(offset);
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
}
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
canvas.style.marginTop = margin.top + 'px';
2014-11-25 21:13:13 +00:00
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
if (margin.top !== 0)
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
{
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
margin.bottom = -(parentBounds.height - canvasBounds.height - margin.top);
canvas.style.marginBottom = margin.bottom + 'px';
}
}
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
// Silly backwards compatibility..
margin.x = margin.left;
margin.y = margin.top;
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
},
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
/**
* Updates the Game state / size.
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
*
* The canvas margins may always be adjusted, even if alignment is not in effect.
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
*
* @method Phaser.ScaleManager#reflowGame
* @private
*/
2014-11-25 21:13:13 +00:00
reflowGame: function () {
this.resetCanvas('', '');
var bounds = this.getParentBounds(this._tempBounds);
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.updateDimensions(bounds.width, bounds.height, true);
},
2013-10-01 12:54:29 +00:00
/**
* Updates the Display canvas size.
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
*
* The canvas margins may always be adjusted, even alignment is not in effect.
*
* @method Phaser.ScaleManager#reflowCanvas
* @private
2013-10-01 12:54:29 +00:00
*/
reflowCanvas: function () {
if (!this.incorrectOrientation)
{
this.width = Phaser.Math.clamp(this.width, this.minWidth || 0, this.maxWidth || this.width);
this.height = Phaser.Math.clamp(this.height, this.minHeight || 0, this.maxHeight || this.height);
}
this.resetCanvas();
2014-03-23 07:59:28 +00:00
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
if (!this.compatibility.noMargins)
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
{
if (this.isFullScreen && this._createdFullScreenTarget)
{
this.alignCanvas(true, true);
}
else
{
this.alignCanvas(this.pageAlignHorizontally, this.pageAlignVertically);
}
}
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.updateScalingAndBounds();
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
},
/**
* "Reset" the Display canvas and set the specified width/height.
*
* @method Phaser.ScaleManager#resetCanvas
* @private
* @param {string} [cssWidth=(current width)] - The css width to set.
* @param {string} [cssHeight=(current height)] - The css height to set.
*/
resetCanvas: function (cssWidth, cssHeight) {
if (cssWidth === undefined) { cssWidth = this.width + 'px'; }
if (cssHeight === undefined) { cssHeight = this.height + 'px'; }
var canvas = this.game.canvas;
2014-11-25 21:13:13 +00:00
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
if (!this.compatibility.noMargins)
{
canvas.style.marginLeft = '';
canvas.style.marginTop = '';
canvas.style.marginRight = '';
canvas.style.marginBottom = '';
}
2014-11-25 21:13:13 +00:00
canvas.style.width = cssWidth;
canvas.style.height = cssHeight;
},
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
/**
* Queues/marks a size/bounds check as needing to occur (from `preUpdate`).
*
* @method Phaser.ScaleManager#queueUpdate
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* @private
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
* @param {boolean} force - If true resets the parent bounds to ensure the check is dirty.
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
*/
queueUpdate: function (force) {
2014-11-25 21:13:13 +00:00
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
if (force)
{
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this._parentBounds.width = 0;
this._parentBounds.height = 0;
}
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
this._updateThrottle = this._updateThrottleReset;
2014-11-25 21:13:13 +00:00
},
2014-10-31 10:29:54 +00:00
/**
* Reset internal data/state.
*
* @method Phaser.ScaleManager#reset
* @private
*/
reset: function (clearWorld) {
if (clearWorld && this.grid)
{
this.grid.reset();
}
},
2013-10-01 12:54:29 +00:00
/**
* Updates the width/height to that of the window.
*
* @method Phaser.ScaleManager#setMaximum
* @private
2013-10-01 12:54:29 +00:00
*/
setMaximum: function () {
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
this.width = this.dom.visualBounds.width;
2014-11-18 07:56:30 +00:00
this.height = this.dom.visualBounds.height;
},
2013-10-01 12:54:29 +00:00
/**
2014-10-31 10:29:54 +00:00
* Updates the width/height such that the game is scaled proportionally.
*
* @method Phaser.ScaleManager#setShowAll
* @private
* @param {boolean} expanding - If true then the maximizing dimension is chosen.
2013-10-01 12:54:29 +00:00
*/
setShowAll: function (expanding) {
var bounds = this.getParentBounds(this._tempBounds);
var width = bounds.width;
var height = bounds.height;
var multiplier;
2014-11-25 21:13:13 +00:00
if (expanding)
{
multiplier = Math.max((height / this.game.height), (width / this.game.width));
}
else
{
multiplier = Math.min((height / this.game.height), (width / this.game.width));
}
this.width = Math.round(this.game.width * multiplier);
this.height = Math.round(this.game.height * multiplier);
},
2013-10-01 12:54:29 +00:00
/**
2014-10-31 10:29:54 +00:00
* Updates the width/height such that the game is stretched to the available size.
* Honors {@link #maxWidth} and {@link #maxHeight} when _not_ in fullscreen.
*
* @method Phaser.ScaleManager#setExactFit
* @private
2013-10-01 12:54:29 +00:00
*/
setExactFit: function () {
var bounds = this.getParentBounds(this._tempBounds);
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.width = bounds.width;
this.height = bounds.height;
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
if (this.isFullScreen)
{
// Max/min not honored fullscreen
return;
}
if (this.maxWidth)
{
this.width = Math.min(this.width, this.maxWidth);
}
if (this.maxHeight)
{
this.height = Math.min(this.height, this.maxHeight);
}
},
/**
* Creates a fullscreen target. This is called automatically as as needed when entering
* fullscreen mode and the resulting element is supplied to {@link #onFullScreenInit}.
*
* Use {@link #onFullScreenInit} to customize the created object.
*
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* @method Phaser.ScaleManager#createFullScreenTarget
* @protected
*/
createFullScreenTarget: function () {
2014-11-25 21:13:13 +00:00
var fsTarget = document.createElement('div');
2014-11-25 21:13:13 +00:00
fsTarget.style.margin = '0';
fsTarget.style.padding = '0';
fsTarget.style.background = '#000';
2014-11-25 21:13:13 +00:00
return fsTarget;
2014-11-25 21:13:13 +00:00
},
/**
2014-12-03 03:18:52 +00:00
* Start the browsers fullscreen mode - this _must_ be called from a user input Pointer or Mouse event.
*
* The Fullscreen API must be supported by the browser for this to work - it is not the same as setting
* the game size to fill the browser window. See {@link Phaser.ScaleManager#compatibility compatibility.supportsFullScreen} to check if the current
* device is reported to support fullscreen mode.
*
* The {@link #fullScreenFailed} signal will be dispatched if the fullscreen change request failed or the game does not support the Fullscreen API.
*
* @method Phaser.ScaleManager#startFullScreen
* @public
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
* @param {boolean} [antialias] - Changes the anti-alias feature of the canvas before jumping in to fullscreen (false = retain pixel art, true = smooth art). If not specified then no change is made. Only works in CANVAS mode.
2014-12-03 03:18:52 +00:00
* @param {boolean} [allowTrampoline=undefined] - Internal argument. If `false` click trampolining is suppressed.
2014-10-31 10:29:54 +00:00
* @return {boolean} Returns true if the device supports fullscreen mode and fullscreen mode was attempted to be started. (It might not actually start, wait for the signals.)
*/
startFullScreen: function (antialias, allowTrampoline) {
if (this.isFullScreen)
{
return false;
}
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
if (!this.compatibility.supportsFullScreen)
{
// Error is called in timeout to emulate the real fullscreenerror event better
var _this = this;
setTimeout(function () {
_this.fullScreenError();
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
}, 10);
return;
}
if (this.compatibility.clickTrampoline === 'when-not-mouse')
{
var input = this.game.input;
if (input.activePointer &&
input.activePointer !== input.mousePointer &&
(allowTrampoline || allowTrampoline !== false))
{
input.activePointer.addClickTrampoline("startFullScreen", this.startFullScreen, this, [antialias, false]);
return;
}
}
if (typeof antialias !== 'undefined' && this.game.renderType === Phaser.CANVAS)
{
this.game.stage.smoothed = antialias;
}
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
var fsTarget = this.fullScreenTarget;
if (!fsTarget)
{
this.cleanupCreatedTarget();
this._createdFullScreenTarget = this.createFullScreenTarget();
fsTarget = this._createdFullScreenTarget;
}
var initData = {
targetElement: fsTarget
};
2014-11-25 21:13:13 +00:00
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
this.onFullScreenInit.dispatch(this, initData);
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
if (this._createdFullScreenTarget)
{
// Move the Display canvas inside of the target and add the target to the DOM
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
// (The target has to be added for the Fullscreen API to work.)
var canvas = this.game.canvas;
var parent = canvas.parentNode;
parent.insertBefore(fsTarget, canvas);
fsTarget.appendChild(canvas);
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
}
if (this.game.device.fullscreenKeyboard)
{
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
fsTarget[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT);
}
else
{
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
fsTarget[this.game.device.requestFullscreen]();
}
return true;
},
/**
* Stops / exits fullscreen mode, if active.
*
* @method Phaser.ScaleManager#stopFullScreen
* @public
2014-10-31 10:29:54 +00:00
* @return {boolean} Returns true if the browser supports fullscreen mode and fullscreen mode will be exited.
*/
stopFullScreen: function () {
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
if (!this.isFullScreen || !this.compatibility.supportsFullScreen)
{
return false;
}
document[this.game.device.cancelFullscreen]();
return true;
},
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
/**
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
* Cleans up the previous fullscreen target, if such was automatically created.
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* This ensures the canvas is restored to its former parent, assuming the target didn't move.
*
2014-11-25 21:13:13 +00:00
* @method Phaser.ScaleManager#cleanupCreatedTarget
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* @private
*/
cleanupCreatedTarget: function () {
var fsTarget = this._createdFullScreenTarget;
2014-11-25 21:13:13 +00:00
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
if (fsTarget && fsTarget.parentNode)
{
// Make sure to cleanup synthetic target for sure;
// swap the canvas back to the parent.
var parent = fsTarget.parentNode;
parent.insertBefore(this.game.canvas, fsTarget);
parent.removeChild(fsTarget);
}
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
this._createdFullScreenTarget = null;
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
},
/**
* Used to prepare/restore extra fullscreen mode settings.
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* (This does move any elements within the DOM tree.)
*
* @method Phaser.ScaleManager#prepScreenMode
* @private
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* @param {boolean} enteringFullscreen - True if _entering_ fullscreen, false if _leaving_.
*/
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
prepScreenMode: function (enteringFullscreen) {
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
var createdTarget = !!this._createdFullScreenTarget;
var fsTarget = this._createdFullScreenTarget || this.fullScreenTarget;
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
if (enteringFullscreen)
{
if (createdTarget || this.fullScreenScaleMode === Phaser.ScaleManager.EXACT_FIT)
{
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
// Resize target, as long as it's not the canvas
if (fsTarget !== this.game.canvas)
{
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
this._fullScreenRestore = {
targetWidth: fsTarget.style.width,
targetHeight: fsTarget.style.height
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
};
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
fsTarget.style.width = '100%';
fsTarget.style.height = '100%';
}
}
}
else
{
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
// Have restore information
if (this._fullScreenRestore)
{
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
fsTarget.style.width = this._fullScreenRestore.targetWidth;
fsTarget.style.height = this._fullScreenRestore.targetHeight;
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this._fullScreenRestore = null;
}
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
// Always reset to game size
this.updateDimensions(this._gameSize.width, this._gameSize.height, true);
this.resetCanvas();
}
},
/**
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
* Called automatically when the browser enters of leaves fullscreen mode.
*
* @method Phaser.ScaleManager#fullScreenChange
* @private
* @param {Event} [event=undefined] - The fullscreenchange event
*/
fullScreenChange: function (event) {
this.event = event;
if (this.isFullScreen)
{
this.prepScreenMode(true);
this.updateLayout();
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.queueUpdate(true);
}
else
{
this.prepScreenMode(false);
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.cleanupCreatedTarget();
this.updateLayout();
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.queueUpdate(true);
}
this.onFullScreenChange.dispatch(this, this.width, this.height);
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
},
/**
* Called automatically when the browser fullscreen request fails;
* or called when a fullscreen request is made on a device for which it is not supported.
*
* @method Phaser.ScaleManager#fullScreenError
* @private
* @param {Event} [event=undefined] - The fullscreenerror event; undefined if invoked on a device that does not support the Fullscreen API.
*/
fullScreenError: function (event) {
this.event = event;
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.cleanupCreatedTarget();
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
console.warn('Phaser.ScaleManager: requestFullscreen failed or device does not support the Fullscreen API');
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
this.onFullScreenError.dispatch(this);
},
/**
* Takes a Sprite or Image object and scales it to fit the given dimensions.
* Scaling happens proportionally without distortion to the sprites texture.
* The letterBox parameter controls if scaling will produce a letter-box effect or zoom the
* sprite until it fills the given values. Note that with letterBox set to false the scaled sprite may spill out over either
* the horizontal or vertical sides of the target dimensions. If you wish to stop this you can crop the Sprite.
*
* @method Phaser.ScaleManager#scaleSprite
* @protected
* @param {Phaser.Sprite|Phaser.Image} sprite - The sprite we want to scale.
* @param {integer} [width] - The target width that we want to fit the sprite in to. If not given it defaults to ScaleManager.width.
* @param {integer} [height] - The target height that we want to fit the sprite in to. If not given it defaults to ScaleManager.height.
* @param {boolean} [letterBox=false] - True if we want the `fitted` mode. Otherwise, the function uses the `zoom` mode.
* @return {Phaser.Sprite|Phaser.Image} The scaled sprite.
*/
scaleSprite: function (sprite, width, height, letterBox) {
if (width === undefined) { width = this.width; }
if (height === undefined) { height = this.height; }
if (letterBox === undefined) { letterBox = false; }
2015-05-12 12:02:40 +00:00
if (!sprite || !sprite['scale'])
{
return sprite;
}
sprite.scale.x = 1;
sprite.scale.y = 1;
if ((sprite.width <= 0) || (sprite.height <= 0) || (width <= 0) || (height <= 0))
{
return sprite;
}
var scaleX1 = width;
var scaleY1 = (sprite.height * width) / sprite.width;
var scaleX2 = (sprite.width * height) / sprite.height;
var scaleY2 = height;
var scaleOnWidth = (scaleX2 > width);
if (scaleOnWidth)
{
scaleOnWidth = letterBox;
}
else
{
scaleOnWidth = !letterBox;
}
if (scaleOnWidth)
{
sprite.width = Math.floor(scaleX1);
sprite.height = Math.floor(scaleY1);
}
else
{
sprite.width = Math.floor(scaleX2);
sprite.height = Math.floor(scaleY2);
}
// Enable at some point?
// sprite.x = Math.floor((width - sprite.width) / 2);
// sprite.y = Math.floor((height - sprite.height) / 2);
return sprite;
},
/**
* Destroys the ScaleManager and removes any event listeners.
* This should probably only be called when the game is destroyed.
*
* @method Phaser.ScaleManager#destroy
* @protected
*/
destroy: function () {
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
this.game.onResume.remove(this._gameResumed, this);
window.removeEventListener('orientationchange', this._orientationChange, false);
window.removeEventListener('resize', this._windowResize, false);
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
if (this.compatibility.supportsFullScreen)
{
document.removeEventListener('webkitfullscreenchange', this._fullScreenChange, false);
document.removeEventListener('mozfullscreenchange', this._fullScreenChange, false);
document.removeEventListener('MSFullscreenChange', this._fullScreenChange, false);
document.removeEventListener('fullscreenchange', this._fullScreenChange, false);
document.removeEventListener('webkitfullscreenerror', this._fullScreenError, false);
document.removeEventListener('mozfullscreenerror', this._fullScreenError, false);
document.removeEventListener('MSFullscreenError', this._fullScreenError, false);
document.removeEventListener('fullscreenerror', this._fullScreenError, false);
}
}
};
Phaser.ScaleManager.prototype.constructor = Phaser.ScaleManager;
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
/**
* The DOM element that is considered the Parent bounding element, if any.
*
* This `null` if {@link #parentIsWindow} is true or if fullscreen mode is entered and {@link #fullScreenTarget} is specified.
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* It will also be null if there is no game canvas or if the game canvas has no parent.
*
2014-11-25 21:13:13 +00:00
* @name Phaser.ScaleManager#boundingParent
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* @property {?DOMElement} boundingParent
* @readonly
*/
Object.defineProperty(Phaser.ScaleManager.prototype, "boundingParent", {
get: function () {
if (this.parentIsWindow ||
(this.isFullScreen && !this._createdFullScreenTarget))
{
return null;
}
var parentNode = this.game.canvas && this.game.canvas.parentNode;
return parentNode || null;
}
});
/**
* The scaling method used by the ScaleManager when not in fullscreen.
*
* <dl>
* <dt>{@link Phaser.ScaleManager.NO_SCALE}</dt>
* <dd>
* The Game display area will not be scaled - even if it is too large for the canvas/screen.
* This mode _ignores_ any applied scaling factor and displays the canvas at the Game size.
* </dd>
* <dt>{@link Phaser.ScaleManager.EXACT_FIT}</dt>
* <dd>
* The Game display area will be _stretched_ to fill the entire size of the canvas's parent element and/or screen.
* Proportions are not maintained.
* </dd>
* <dt>{@link Phaser.ScaleManager.SHOW_ALL}</dt>
* <dd>
* Show the entire game display area while _maintaining_ the original aspect ratio.
* </dd>
* <dt>{@link Phaser.ScaleManager.RESIZE}</dt>
* <dd>
* The dimensions of the game display area are changed to match the size of the parent container.
* That is, this mode _changes the Game size_ to match the display size.
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* <p>
* Any manually set Game size (see {@link #setGameSize}) is ignored while in effect.
* </dd>
* <dt>{@link Phaser.ScaleManager.USER_SCALE}</dt>
* <dd>
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* The game Display is scaled according to the user-specified scale set by {@link Phaser.ScaleManager#setUserScale setUserScale}.
* <p>
* This scale can be adjusted in the {@link Phaser.ScaleManager#setResizeCallback resize callback}
* for flexible custom-sizing needs.
* </dd>
* </dl>
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
*
* @name Phaser.ScaleManager#scaleMode
* @property {integer} scaleMode
*/
Object.defineProperty(Phaser.ScaleManager.prototype, "scaleMode", {
get: function () {
return this._scaleMode;
},
set: function (value) {
if (value !== this._scaleMode)
{
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
if (!this.isFullScreen)
{
this.updateDimensions(this._gameSize.width, this._gameSize.height, true);
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.queueUpdate(true);
}
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this._scaleMode = value;
}
return this._scaleMode;
}
});
/**
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
* The scaling method used by the ScaleManager when in fullscreen.
*
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* See {@link Phaser.ScaleManager#scaleMode scaleMode} for the different modes allowed.
*
* @name Phaser.ScaleManager#fullScreenScaleMode
* @property {integer} fullScreenScaleMode
*/
Object.defineProperty(Phaser.ScaleManager.prototype, "fullScreenScaleMode", {
get: function () {
return this._fullScreenScaleMode;
},
set: function (value) {
if (value !== this._fullScreenScaleMode)
{
// If in fullscreen then need a wee bit more work
if (this.isFullScreen)
{
this.prepScreenMode(false);
this._fullScreenScaleMode = value;
this.prepScreenMode(true);
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.queueUpdate(true);
}
else
{
this._fullScreenScaleMode = value;
}
}
return this._fullScreenScaleMode;
}
});
/**
* Returns the current scale mode - for normal or fullscreen operation.
*
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
* See {@link Phaser.ScaleManager#scaleMode scaleMode} for the different modes allowed.
*
* @name Phaser.ScaleManager#currentScaleMode
* @property {number} currentScaleMode
* @protected
* @readonly
*/
Object.defineProperty(Phaser.ScaleManager.prototype, "currentScaleMode", {
get: function () {
return this.isFullScreen ? this._fullScreenScaleMode : this._scaleMode;
}
});
/**
* When enabled the Display canvas will be horizontally-aligned _in the Parent container_ (or {@link Phaser.ScaleManager#parentIsWindow window}).
*
* To align horizontally across the page the Display canvas should be added directly to page;
* or the parent container should itself be horizontally aligned.
*
* Horizontal alignment is not applicable with the {@link .RESIZE} scaling mode.
*
* @name Phaser.ScaleManager#pageAlignHorizontally
* @property {boolean} pageAlignHorizontally
* @default false
*/
Object.defineProperty(Phaser.ScaleManager.prototype, "pageAlignHorizontally", {
get: function () {
return this._pageAlignHorizontally;
},
set: function (value) {
if (value !== this._pageAlignHorizontally)
{
this._pageAlignHorizontally = value;
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.queueUpdate(true);
}
}
});
/**
* When enabled the Display canvas will be vertically-aligned _in the Parent container_ (or {@link Phaser.ScaleManager#parentIsWindow window}).
*
* To align vertically the Parent element should have a _non-collapsible_ height, such that it will maintain
* a height _larger_ than the height of the contained Game canvas - the game canvas will then be scaled vertically
* _within_ the remaining available height dictated by the Parent element.
*
* One way to prevent the parent from collapsing is to add an absolute "min-height" CSS property to the parent element.
* If specifying a relative "min-height/height" or adjusting margins, the Parent height must still be non-collapsible (see note).
*
* _Note_: In version 2.2 the minimum document height is _not_ automatically set to the viewport/window height.
* To automatically update the minimum document height set {@link Phaser.ScaleManager#compatibility compatibility.forceMinimumDocumentHeight} to true.
*
* Vertical alignment is not applicable with the {@link .RESIZE} scaling mode.
*
* @name Phaser.ScaleManager#pageAlignVertically
* @property {boolean} pageAlignVertically
* @default false
*/
Object.defineProperty(Phaser.ScaleManager.prototype, "pageAlignVertically", {
get: function () {
return this._pageAlignVertically;
},
set: function (value) {
if (value !== this._pageAlignVertically)
{
this._pageAlignVertically = value;
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
this.queueUpdate(true);
}
}
});
2013-10-01 12:54:29 +00:00
/**
ScaleManager: additional cleanup - Added `compatibility` settings - CHANGE (2.1.2-4): moved `supportsFullScreen` and `noMargins` into it - Added additional properties for greater control and up-front settings. - `scrollTo`: where the browser will scrollTo, if anywhere - `forceMinimumDocumentHeight`: apply document element style? - `allowShowAllExpand`: allow SHOW_ALL to try to expand? (It already could, this allows configuration.) - Removed `windowConstraints.top/left`. This may be a feature in the future, but scrubbed for now. - Added `USER_SCALE` scale mode. This is like NO_SCALE but it scales off of a user-specified scale factor, as set by `setUserScale`. This is marked as "experimental" as the exactly semantics of non-adjusting modes (e.g. NO_SCALE and USER_SCALE) wrt. Canvas and "maximum" size clamps need to be re-examined. - FIX: `onSizeChange` now works as documented, which means it is also fired if the game size changes even though the game canvas size does not. - CHANGE (no known breaking): `margins` is now non-Point/non-Rectangle that uses top/left/bottom/right properties (any quasi-updated x/y). This is to get around the issue that Rectangle is only designed for positive width/height cases. - Cleaned up property access / quotes for consistency - Various documentation cleanup and consistency - Fixed issue with not clearing an unparented `_createdFullScreenTarget` - Added Phaser.Rectangle.sameDimensions which does a strict equality check over the `width` and `height` properties of two objects, perhaps Rectangles.
2014-11-09 00:38:21 +00:00
* Returns true if the browser is in fullscreen mode, otherwise false.
* @name Phaser.ScaleManager#isFullScreen
* @property {boolean} isFullScreen
2013-10-03 00:21:08 +00:00
* @readonly
2013-10-01 12:54:29 +00:00
*/
Object.defineProperty(Phaser.ScaleManager.prototype, "isFullScreen", {
get: function () {
return !!(document['fullscreenElement'] ||
document['webkitFullscreenElement'] ||
document['mozFullScreenElement'] ||
document['msFullscreenElement']);
}
});
2013-10-01 12:54:29 +00:00
/**
* Returns true if the screen orientation is in portrait mode.
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
*
* @name Phaser.ScaleManager#isPortrait
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* @property {boolean} isPortrait
2013-10-03 00:21:08 +00:00
* @readonly
2013-10-01 12:54:29 +00:00
*/
Object.defineProperty(Phaser.ScaleManager.prototype, "isPortrait", {
get: function () {
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
return this.classifyOrientation(this.screenOrientation) === 'portrait';
}
});
2013-10-01 12:54:29 +00:00
/**
* Returns true if the screen orientation is in landscape mode.
ScaleManager + DOM "Final" changes for a solid 2.2-worthy ScaleManager. This adds in official support for USER_SCALE, which allows a flexible way to control the scaling dynamically. It fixes a visible display bug in desktop browsers (viewport clipping was off) and mitigates some potential issues all around by using a unified visualBound calculations in Phaser.DOM. It applies some protected/deprecated attributes, but does not remove any behavior of already-established (as in, outside-dev) means. There are no known [signficant] breaking changes; any known breaks (not considered fixes) are constrained to dev with no known consumers. Phaser.DOM There are no known significant breaking changes; Phaser.DOM was internal. - Added visualBounds; this should be the true visual area, minus the scrollbars. This should be used instead of clientWidth/clientHeight to detect the visual viewport. - Expose various viewport sizes as dynamically updated properties on Rectangle objects. These are visualBounds, layoutBounds, documentBounds. - Updated documentation the different bounds; in particular drawing distinction between viewport/layout bounds and visual bounds. - Renamed `inViewport` to `inLayoutViewport` to indidcate behavior. - Minor breaking, but dev-only - Changed `getAspectRatio` to work on Visual viewport. This will yield the expected behavior on mobiles. - Minor breaking, but dev-only - Removed some quirks-mode and legacy-browser special casing Phaser.ScaleManager There are no known significant breaking changes. - USER_SCALE is 'made public'. It can used to flexibly configure any custom-yet-dynamic scaling requirements; it should now be able to replace any sane usage of manual sizing invoking the deprecated setSize/setScreenSize. - Added additional usage documentation and links to such - Added the ability to specify a post-scale trim factor. - Change the arguments the resize callback and document what is passed - Minor breaking, but the previous arguments were undocumented - `compatiblity.showAllCanExpand` renamed to `canExpandParent` and made generalized over possibly-expanding scaling. - Minor breaking, dev-only, for coding changing this settin - Switched from direct usage of of window innerWidth/Heigth to Phaser.DOM visualViewport - this change correctly accounts for scrollbars in desktop environments - Although it does slightly alter the behavior, this is a fix. - Removed usage of window outerWidth/outerHeight which didn't make much sense where it was used for desktops and was catostrophic for mobile browser - Although it may slightly alter the behavior, this is a fix. - Removed `aspect` and `elementBounds` because they are duplicative of Phaser.DOM (which can not be accessed as `scale.dom`). - Minor breaking, but internal methods on dev-only - Marked the minWidth/maxWidth/minHeight/maxHeight properties as protected. They are not removed/obsoleted, but should be revised later for more flexibility. - Orientation handling; non-breaking forward deprecations - Added `onOrientationChange` and deprecated the 4 separate leave, enter, landscape and portrait signals. They are not removed, so this is a future-migration change. - Fixed issue where state not updated prior to callback - Fixed issue where orientation callbacks were not always delayed - Fullscreen events: non-breaking forward deprecations - Added `onFullScreenChange` and deprecated `enterFullScreen` and `leaveFullScreen`. - Renamed (with proxy) `fullScreenFailed` to `onFullScreenError`. Phaser.Device - Improved `whenReady` to support Phaser.DOM better - Allows a ready handler to be added without starting the device-detection proccess. This allows it to be registered to internally (eg. from System.DOM) without affecting current behavior. - Passes the device object as the first parameter to the callback function. - Fixed code where Silk detection not applied to `desktop` detection. Manifest: System.Device moved before System.DOM
2014-11-16 09:00:54 +00:00
*
* @name Phaser.ScaleManager#isLandscape
ScaleManager - scaling consistency and bug-fixes This includes some minor breaking changes. - Unifies SHOW_ALL and NO_SCALE being stretched in Firefox and IE - As suggested by MDN: "..to emulate WebKit's behavior on Gecko, you need to place the element you want to present inside another element.." - This done via an (overwritable) `createFullScreenTarget` function. The (new) DOM element returned from this is placed into the DOM and the canvas is added to (and later removed) as the full screen mode changes. - MINOR BREAK: may affect code that assumes the Phaser canvas has a fixed DOM/CSS path (which should hopefully be nobody). To use to the original behavior, where the canvas is not moved, simply set `this.fullScreenTarget = game.canvas` manually. - Updates the refresh/queue to be unified and uses a smarter back-off to detect and react to parent dimension changes - Cleans up some odd browser issues; not tried on mobile - Fixes an issue were update might be called too much and spend time doing nothing useful. - `maxIterations` is no longer user and marked as deprecated - MINOR BREAK: previous approach would occasionally (but not always) back off updates the entire iteration/setTimeout sequence; under the new approach "onResize" may be called more frequently. - Fixes a number various transition issues, mostly around RESIZE - MINOR BREAK, but correct: leaving RESIZE restores the original game size possible - Fixes assorted quirks with scales not being updated - Layout - MINOR BREAK: All Canvas margins are "OWNED" by the ScaleManager. They will be reset in all modes as appropriate. This is for consistency fixes as well as coping with the updated full screen. - MINOR BREAK: Canvas right/bottom margins are set to negative margins to counter left/top margins. This prevents Canvas margin adjustments from affecting the flow .. much. - `getParentBounds` rounds to the nearest pixel to avoid "close to" value propagation from CSS. - Fixes page-align center pushing canvas out of parent - Misc. - MINOR BREAK: `setScreenSize` will update the game size if the mode is RESIZE. User-code shoulde use `refresh` instead to ensure that any relevant changes are propagated. - Corrected incorrect documentation
2014-11-07 21:18:56 +00:00
* @property {boolean} isLandscape
2013-10-03 00:21:08 +00:00
* @readonly
2013-10-01 12:54:29 +00:00
*/
Object.defineProperty(Phaser.ScaleManager.prototype, "isLandscape", {
get: function () {
ScaleManager - orientation - FIX #1306, hopefully, where an orientation change did not correclty cause a screen/layout update. - FIX/CHANGE where Paused games would not update the scale - The new behavior "runs" the ScaleManager in a paused state via `pauseUpdate`; a User paused game will now correctly track scale changes. This is closer to the 2.1.3 behavior in some cases, such as window resizing, when the updates were done in the DOM event. - This change also affects device orientation change monitoring and events, which are also deferred to the update cycle - The update cycle is set to the maximum and is still dependent on the RAF / primary loop running, so it should not affect background apps/tabs - FIX/CHANGE New better backoff timing; ie. continuous window resizing is limited to ~10 fps update calculations. This makes it much harder to crash Chrome by rapidly and continously resizing the window. Also increases the scaling from 0..10..20..40 to 0..25..50..100. - FIX an issue where the incorrect orientation was "one frame behind" the scaling. - UPDATE The contract for when the change orientation events occurs is better defined - it now always happens in the update context as with game sizing. - UPDATE Unifies orientation-change code / handling and duplicate. - CHANGE Added DOM.getScreenOrientation which obtains the orientation via the Device Orientation API (WD) and provides comprehensive fallbacks - This should cover all modern browsers - FIX: Orientation on desktops now computed as screen ratio by default which fixesi the false-portrait chain/detection when the page is made more narrow than it is tall. - CHANGE/FIX: window.orientation is now only used as fallback, if requested (due to device differences). It may be appropriate to enable this (via `scale.compatibility` on boot, for instance) in some environments. Signed-off-by: Paul <pstickne@gmail.com>
2014-11-12 06:30:01 +00:00
return this.classifyOrientation(this.screenOrientation) === 'landscape';
}
});
/**
* Returns true if the game dimensions are portrait (height > width).
* This is especially useful to check when using the RESIZE scale mode
* but wanting to maintain game orientation on desktop browsers,
* where typically the screen orientation will always be landscape regardless of the browser viewport.
*
* @name Phaser.ScaleManager#isGamePortrait
* @property {boolean} isGamePortrait
* @readonly
*/
Object.defineProperty(Phaser.ScaleManager.prototype, "isGamePortrait", {
get: function () {
return (this.height > this.width);
}
});
/**
* Returns true if the game dimensions are landscape (width > height).
* This is especially useful to check when using the RESIZE scale mode
* but wanting to maintain game orientation on desktop browsers,
* where typically the screen orientation will always be landscape regardless of the browser viewport.
*
* @name Phaser.ScaleManager#isGameLandscape
* @property {boolean} isGameLandscape
* @readonly
*/
Object.defineProperty(Phaser.ScaleManager.prototype, "isGameLandscape", {
get: function () {
return (this.width > this.height);
}
});