Skip to content

Commit ee579c2

Browse files
committed
Merge pull request phaserjs#989 from lucbloom/android-stock-browser
Android stock browser check
2 parents 31f450d + 4183237 commit ee579c2

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/system/Device.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,3 +900,16 @@ Phaser.Device.prototype = {
900900
};
901901

902902
Phaser.Device.prototype.constructor = Phaser.Device;
903+
904+
/**
905+
* A class-static function to check wether we’re running on an Android Stock browser.
906+
* Autors might want to scale down on effects and switch to the CANVAS rendering method on those devices.
907+
* Usage: var defaultRenderingMode = Phaser.Device.isAndroidStockBrowser() ? Phaser.CANVAS : Phaser.AUTO;
908+
*
909+
* @function Phaser.Device#isAndroidStockBrowser
910+
*/
911+
Phaser.Device.isAndroidStockBrowser = function()
912+
{
913+
var matches = window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]+)/);
914+
return matches && matches[1] < 537;
915+
};

0 commit comments

Comments
 (0)