Skip to content

Commit 4183237

Browse files
committed
Android stock browser check
This is a class-static function of Phaser.Device to check wether we’re running on an Android Stock browser. Autors might want to scale down on effects and switch to the CANVAS rendering method on those devices. Usage: var defaultRenderingMode = Phaser.Device.isAndroidStockBrowser() ? Phaser.CANVAS : Phaser.AUTO;
1 parent 6a0b8b5 commit 4183237

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
@@ -879,3 +879,16 @@ Phaser.Device.prototype = {
879879
};
880880

881881
Phaser.Device.prototype.constructor = Phaser.Device;
882+
883+
/**
884+
* A class-static function to check wether we’re running on an Android Stock browser.
885+
* Autors might want to scale down on effects and switch to the CANVAS rendering method on those devices.
886+
* Usage: var defaultRenderingMode = Phaser.Device.isAndroidStockBrowser() ? Phaser.CANVAS : Phaser.AUTO;
887+
*
888+
* @function Phaser.Device#isAndroidStockBrowser
889+
*/
890+
Phaser.Device.isAndroidStockBrowser = function()
891+
{
892+
var matches = window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]+)/);
893+
return matches && matches[1] < 537;
894+
};

0 commit comments

Comments
 (0)