Device.quirksMode is a boolean that informs you if the page is in strict (false) or quirks (true) mode.

Canvas.getOffset now runs a strict/quirks check and uses document.documentElement when calculating scrollTop and scrollLeft to avoid Chrome console warnings.
The Time class now has three new methods: addEvent, repeatEvent and loopEvent. See the new Timer examples to show how to use them.
This commit is contained in:
photonstorm
2014-01-08 11:21:48 +00:00
parent 67e2caafbc
commit 35e61172e1
7 changed files with 179 additions and 62 deletions
+17 -3
View File
@@ -5,7 +5,7 @@
*/
/**
* The Canvas class handles everything related to the <canvas> tag as a DOM Element, like styles, offset, aspect ratio
* The Canvas class handles everything related to creating the `canvas` DOM tag that Phaser will use, including styles, offset and aspect ratio.
*
* @class Phaser.Canvas
* @static
@@ -56,8 +56,22 @@ Phaser.Canvas = {
var box = element.getBoundingClientRect();
var clientTop = element.clientTop || document.body.clientTop || 0;
var clientLeft = element.clientLeft || document.body.clientLeft || 0;
var scrollTop = window.pageYOffset || element.scrollTop || document.body.scrollTop;
var scrollLeft = window.pageXOffset || element.scrollLeft || document.body.scrollLeft;
// Without this check Chrome is now throwing console warnings about strict vs. quirks :(
var scrollTop = 0;
var scrollLeft = 0;
if (document.compatMode === 'CSS1Compat')
{
scrollTop = window.pageYOffset || document.documentElement.scrollTop || element.scrollTop || 0;
scrollLeft = window.pageXOffset || document.documentElement.scrollLeft || element.scrollLeft || 0;
}
else
{
scrollTop = window.pageYOffset || document.body.scrollTop || element.scrollTop || 0;
scrollLeft = window.pageXOffset || document.body.scrollLeft || element.scrollLeft || 0;
}
point.x = box.left + scrollLeft - clientLeft;
point.y = box.top + scrollTop - clientTop;
+8
View File
@@ -150,6 +150,12 @@ Phaser.Device = function () {
*/
this.vibration = false;
/**
* @property {boolean} quirksMode - Is the browser running in strict mode (false) or quirks mode? (true)
* @default
*/
this.quirksMode = false;
// Browser
/**
@@ -414,6 +420,8 @@ Phaser.Device.prototype = {
this.pointerLock = 'pointerLockElement' in document || 'mozPointerLockElement' in document || 'webkitPointerLockElement' in document;
this.quirksMode = (document.compatMode === 'CSS1Compat') ? false : true;
},
/**