phaser/wip/utils/DOM.js

433 lines
14 KiB
JavaScript
Raw Normal View History

/**
* @author Richard Davey <rich@photonstorm.com>
2016-04-04 21:15:01 +00:00
* @copyright 2016 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* DOM utility class.
*
* Provides a useful Window and Element functions as well as cross-browser compatibility buffer.
*
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
* Some code originally derived from {@link https://github.com/ryanve/verge verge}.
2014-12-01 21:05:53 +00:00
* Some parts were inspired by the research of Ryan Van Etten, released under MIT License 2013.
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
*
* @class Phaser.DOM
* @static
*/
Phaser.DOM = {
/**
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
* Get the [absolute] position of the element relative to the Document.
*
* The value may vary slightly as the page is scrolled due to rounding errors.
*
* @method Phaser.DOM.getOffset
* @param {DOMElement} element - The targeted element that we want to retrieve the offset.
* @param {Phaser.Point} [point] - The point we want to take the x/y values of the offset.
* @return {Phaser.Point} - A point objet with the offsetX and Y as its properties.
*/
getOffset: function (element, point) {
point = point || new Phaser.Point();
var box = element.getBoundingClientRect();
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 scrollTop = Phaser.DOM.scrollY;
var scrollLeft = Phaser.DOM.scrollX;
var clientTop = document.documentElement.clientTop;
var clientLeft = document.documentElement.clientLeft;
point.x = box.left + scrollLeft - clientLeft;
point.y = box.top + scrollTop - clientTop;
return point;
},
/**
* A cross-browser element.getBoundingClientRect method with optional cushion.
*
* Returns a plain object containing the properties `top/bottom/left/right/width/height` with respect to the top-left corner of the current viewport.
* Its properties match the native rectangle.
* The cushion parameter is an amount of pixels (+/-) to cushion the element.
* It adjusts the measurements such that it is possible to detect when an element is near the viewport.
*
* @method Phaser.DOM.getBounds
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
* @param {DOMElement|Object} element - The element or stack (uses first item) to get the bounds for.
* @param {number} [cushion] - A +/- pixel adjustment amount.
* @return {Object|boolean} A plain object containing the properties `top/bottom/left/right/width/height` or `false` if a non-valid element is given.
*/
getBounds: function (element, cushion) {
if (cushion === undefined) { cushion = 0; }
element = element && !element.nodeType ? element[0] : element;
if (!element || element.nodeType !== 1)
{
return false;
}
else
{
return this.calibrate(element.getBoundingClientRect(), cushion);
}
},
/**
* Calibrates element coordinates for `inLayoutViewport` checks.
*
* @method Phaser.DOM.calibrate
* @private
* @param {object} coords - An object containing the following properties: `{top: number, right: number, bottom: number, left: number}`
* @param {number} [cushion] - A value to adjust the coordinates by.
* @return {object} The calibrated element coordinates
*/
calibrate: function (coords, cushion) {
cushion = +cushion || 0;
var output = { width: 0, height: 0, left: 0, right: 0, top: 0, bottom: 0 };
output.width = (output.right = coords.right + cushion) - (output.left = coords.left - cushion);
output.height = (output.bottom = coords.bottom + cushion) - (output.top = coords.top - cushion);
return output;
},
/**
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
* Get the Visual viewport aspect ratio (or the aspect ratio of an object or element)
*
* @method Phaser.DOM.getAspectRatio
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
* @param {(DOMElement|Object)} [object=(visualViewport)] - The object to determine the aspect ratio for. Must have public `width` and `height` properties or methods.
* @return {number} The aspect ratio.
*/
getAspectRatio: function (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
object = null == object ? this.visualBounds : 1 === object.nodeType ? this.getBounds(object) : object;
var w = object['width'];
var h = object['height'];
if (typeof w === 'function')
{
w = w.call(object);
}
if (typeof h === 'function')
{
h = h.call(object);
}
return w / h;
},
/**
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
* Tests if the given DOM element is within the Layout viewport.
*
* The optional cushion parameter allows you to specify a distance.
*
* inLayoutViewport(element, 100) is `true` if the element is in the viewport or 100px near it.
* inLayoutViewport(element, -100) is `true` if the element is in the viewport or at least 100px near it.
*
* @method Phaser.DOM.inLayoutViewport
* @param {DOMElement|Object} element - The DOM element to check. If no element is given it defaults to the Phaser game canvas.
* @param {number} [cushion] - The cushion allows you to specify a distance within which the element must be within the viewport.
* @return {boolean} True if the element is within the viewport, or within `cushion` distance from it.
*/
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
inLayoutViewport: function (element, cushion) {
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 r = this.getBounds(element, cushion);
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 !!r && r.bottom >= 0 && r.right >= 0 && r.top <= this.layoutBounds.width && r.left <= this.layoutBounds.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
},
/**
* Returns the device screen orientation.
*
* Orientation values: 'portrait-primary', 'landscape-primary', 'portrait-secondary', 'landscape-secondary'.
*
* Order of resolving:
* - Screen Orientation API, or variation of - Future track. Most desktop and mobile browsers.
* - Screen size ratio check - If fallback is 'screen', suited for desktops.
* - Viewport size ratio check - If fallback is 'viewport', suited for mobile.
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
* - window.orientation - If fallback is 'window.orientation', works iOS and probably most Android; non-recommended track.
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
* - Media query
* - Viewport size ratio check (probably only IE9 and legacy mobile gets here..)
*
* See
* - https://w3c.github.io/screen-orientation/ (conflicts with mozOrientation/msOrientation)
* - https://developer.mozilla.org/en-US/docs/Web/API/Screen.orientation (mozOrientation)
* - http://msdn.microsoft.com/en-us/library/ie/dn342934(v=vs.85).aspx
* - https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Testing_media_queries
* - http://stackoverflow.com/questions/4917664/detect-viewport-orientation
* - http://www.matthewgifford.com/blog/2011/12/22/a-misconception-about-window-orientation
*
* @method Phaser.DOM.getScreenOrientation
* @protected
* @param {string} [primaryFallback=(none)] - Specify 'screen', 'viewport', or 'window.orientation'.
*/
getScreenOrientation: function (primaryFallback) {
var screen = window.screen;
var orientation = screen.orientation || screen.mozOrientation || screen.msOrientation;
if (orientation && typeof orientation.type === 'string')
{
// Screen Orientation API specification
return orientation.type;
}
else if (typeof orientation === 'string')
{
// moz/ms-orientation are strings
return orientation;
}
var PORTRAIT = 'portrait-primary';
var LANDSCAPE = 'landscape-primary';
if (primaryFallback === 'screen')
{
return (screen.height > screen.width) ? PORTRAIT : LANDSCAPE;
}
else if (primaryFallback === 'viewport')
{
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 (this.visualBounds.height > this.visualBounds.width) ? PORTRAIT : LANDSCAPE;
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 if (primaryFallback === 'window.orientation' && typeof window.orientation === 'number')
{
// This may change by device based on "natural" orientation.
return (window.orientation === 0 || window.orientation === 180) ? PORTRAIT : LANDSCAPE;
}
else if (window.matchMedia)
{
if (window.matchMedia("(orientation: portrait)").matches)
{
return PORTRAIT;
}
2014-11-12 07:02:43 +00:00
else if (window.matchMedia("(orientation: landscape)").matches)
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 LANDSCAPE;
}
}
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 (this.visualBounds.height > this.visualBounds.width) ? PORTRAIT : LANDSCAPE;
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
},
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 bounds of the Visual viewport, as discussed in
* {@link http://www.quirksmode.org/mobile/viewports.html A tale of two viewports — part one}
* with one difference: the viewport size _excludes_ scrollbars, as found on some desktop browsers.
*
* Supported mobile:
* iOS/Safari, Android 4, IE10, Firefox OS (maybe not Firefox Android), Opera Mobile 16
*
* The properties change dynamically.
*
* @type {Phaser.Rectangle}
* @property {number} x - Scroll, left offset - eg. "scrollX"
* @property {number} y - Scroll, top offset - eg. "scrollY"
* @property {number} width - Viewport width in pixels.
* @property {number} height - Viewport height in pixels.
* @readonly
*/
visualBounds: 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
/**
* The bounds of the Layout viewport, as discussed in
* {@link http://www.quirksmode.org/mobile/viewports2.html A tale of two viewports — part two};
* but honoring the constraints as specified applicable viewport meta-tag.
*
* The bounds returned are not guaranteed to be fully aligned with CSS media queries (see
* {@link http://www.matanich.com/2013/01/07/viewport-size/ What size is my viewport?}).
*
* This is _not_ representative of the Visual bounds: in particular the non-primary axis will
* generally be significantly larger than the screen height on mobile devices when running with a
* constrained viewport.
*
* The properties change dynamically.
*
* @type {Phaser.Rectangle}
* @property {number} width - Viewport width in pixels.
* @property {number} height - Viewport height in pixels.
* @readonly
*/
layoutBounds: 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
/**
* The size of the document / Layout viewport.
*
* This incorrectly reports the dimensions in IE.
*
* The properties change dynamically.
*
* @type {Phaser.Rectangle}
* @property {number} width - Document width in pixels.
* @property {number} height - Document height in pixels.
* @readonly
*/
documentBounds: 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
};
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
Phaser.Device.whenReady(function (device) {
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
// All target browsers should support page[XY]Offset.
var scrollX = window && ('pageXOffset' in window) ?
function () { return window.pageXOffset; } :
function () { return document.documentElement.scrollLeft; };
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 scrollY = window && ('pageYOffset' in window) ?
function () { return window.pageYOffset; } :
function () { return document.documentElement.scrollTop; };
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 cross-browser window.scrollX.
*
* @name Phaser.DOM.scrollX
* @property {number} scrollX
* @readonly
* @protected
*/
Object.defineProperty(Phaser.DOM, "scrollX", {
get: scrollX
});
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 cross-browser window.scrollY.
*
* @name Phaser.DOM.scrollY
* @property {number} scrollY
* @readonly
* @protected
*/
Object.defineProperty(Phaser.DOM, "scrollY", {
get: scrollY
});
Object.defineProperty(Phaser.DOM.visualBounds, "x", {
get: scrollX
});
Object.defineProperty(Phaser.DOM.visualBounds, "y", {
get: scrollY
});
Object.defineProperty(Phaser.DOM.layoutBounds, "x", {
value: 0
});
Object.defineProperty(Phaser.DOM.layoutBounds, "y", {
value: 0
});
var treatAsDesktop = device.desktop &&
(document.documentElement.clientWidth <= window.innerWidth) &&
(document.documentElement.clientHeight <= window.innerHeight);
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
// Desktop browsers align the layout viewport with the visual viewport.
// This differs from mobile browsers with their zooming design.
// Ref. http://quirksmode.org/mobile/tableViewport.html
if (treatAsDesktop)
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
{
// PST- When scrollbars are not included this causes upstream issues in ScaleManager.
// So reverted to the old "include scrollbars."
var clientWidth = function () {
return Math.max(window.innerWidth, document.documentElement.clientWidth);
};
var clientHeight = function () {
return Math.max(window.innerHeight, document.documentElement.clientHeight);
};
// Interested in area sans-scrollbar
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
Object.defineProperty(Phaser.DOM.visualBounds, "width", {
get: clientWidth
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 + 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
Object.defineProperty(Phaser.DOM.visualBounds, "height", {
get: clientHeight
});
Object.defineProperty(Phaser.DOM.layoutBounds, "width", {
get: clientWidth
});
Object.defineProperty(Phaser.DOM.layoutBounds, "height", {
get: clientHeight
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
});
} 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
Object.defineProperty(Phaser.DOM.visualBounds, "width", {
get: function () {
return window.innerWidth;
}
});
Object.defineProperty(Phaser.DOM.visualBounds, "height", {
get: function () {
return window.innerHeight;
}
});
Object.defineProperty(Phaser.DOM.layoutBounds, "width", {
get: function () {
var a = document.documentElement.clientWidth;
var b = window.innerWidth;
return a < b ? b : a; // max
}
});
Object.defineProperty(Phaser.DOM.layoutBounds, "height", {
get: function () {
var a = document.documentElement.clientHeight;
var b = window.innerHeight;
return a < b ? b : a; // max
}
});
}
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
// For Phaser.DOM.documentBounds
// Ref. http://www.quirksmode.org/mobile/tableViewport_desktop.html
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
Object.defineProperty(Phaser.DOM.documentBounds, "x", {
value: 0
});
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
Object.defineProperty(Phaser.DOM.documentBounds, "y", {
value: 0
});
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
Object.defineProperty(Phaser.DOM.documentBounds, "width", {
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
get: function () {
var d = document.documentElement;
return Math.max(d.clientWidth, d.offsetWidth, d.scrollWidth);
}
});
Object.defineProperty(Phaser.DOM.documentBounds, "height", {
get: function () {
var d = document.documentElement;
return Math.max(d.clientHeight, d.offsetHeight, d.scrollHeight);
}
});
2014-11-18 07:56:30 +00:00
}, null, true);