Make DEVICE_PIXEL_RATIO work in non-window context
This commit is contained in:
+7
-1
@@ -37,7 +37,13 @@ export const MAC = ua.indexOf('macintosh') !== -1;
|
|||||||
* @type {number}
|
* @type {number}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
export const DEVICE_PIXEL_RATIO = window.devicePixelRatio || 1;
|
export const DEVICE_PIXEL_RATIO = (function() {
|
||||||
|
try {
|
||||||
|
return self.devicePixelRatio;
|
||||||
|
} catch (e) {
|
||||||
|
return window.devicePixelRatio || 1;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Image.prototype.decode() is supported.
|
* Image.prototype.decode() is supported.
|
||||||
|
|||||||
Reference in New Issue
Block a user