Skip to content

Commit f536962

Browse files
committed
Device.chromeVersion will return the major version number of Chrome.
1 parent ee911e2 commit f536962

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ Version 2.4 - "Katar" - in dev
308308
* Ellipse.random will return a uniformly distributed random point from anywhere within the ellipse.
309309
* Rectangle.random will return a uniformly distributed random point from anywhere within the rectangle.
310310
* Line.rotate allows you to rotate a line by the given amount around its center point.
311+
* Device.chromeVersion will return the major version number of Chrome.
311312

312313
### Updates
313314

@@ -382,6 +383,7 @@ Version 2.4 - "Katar" - in dev
382383
* Tween.to and Tween.from can now accept `null` as the ease parameter value. If `null` it will use the default tween, as per the documentation (thanks @nkovacs #1817)
383384
* TilemapParser.parseTiledJSON would ignore 'falsey' properties set on Objects in Tiled JSON tilemaps, such as `x: 0` or `visible: false`. These properties are now accurately copied over to the destination map data (thanks @MaksJS #1818)
384385
* Removed un-necessary PIXI.TextureCache pollution in Phaser.LoaderParser.bitmapFont.
386+
*
385387

386388
For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md).
387389

src/system/Device.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ Phaser.Device = function () {
250250
*/
251251
this.chrome = false;
252252

253+
/**
254+
* @property {number} chromeVersion - If running in Chrome this will contain the major version number.
255+
* @default
256+
*/
257+
this.chromeVersion = 0;
258+
253259
/**
254260
* @property {boolean} epiphany - Set to true if running in Epiphany.
255261
* @default
@@ -712,12 +718,9 @@ Phaser.Device._initialize = function () {
712718
device.getUserMedia = device.getUserMedia && !!navigator.getUserMedia && !!window.URL;
713719

714720
// Older versions of firefox (< 21) apparently claim support but user media does not actually work
715-
if (navigator.userAgent.match(/Firefox\D+(\d+)/))
721+
if (device.firefoxVersion < 21)
716722
{
717-
if (parseInt(RegExp.$1, 10) < 21)
718-
{
719-
device.getUserMedia = false;
720-
}
723+
device.getUserMedia = false;
721724
}
722725

723726
// TODO: replace canvasBitBltShift detection with actual feature check
@@ -845,9 +848,10 @@ Phaser.Device._initialize = function () {
845848
{
846849
device.arora = true;
847850
}
848-
else if (/Chrome/.test(ua))
851+
else if (/Chrome\/(\d+)/.test(ua))
849852
{
850853
device.chrome = true;
854+
device.chromeVersion = parseInt(RegExp.$1, 10);
851855
}
852856
else if (/Epiphany/.test(ua))
853857
{

0 commit comments

Comments
 (0)