Skip to content

Commit 9fbfd61

Browse files
committed
use devicePixelRatio for cordova only
1 parent 8a243ef commit 9fbfd61

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

platform/html5/html.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,16 +524,20 @@ exports.Window = function(context, dom) {
524524
var WindowPrototype = exports.Window.prototype = Object.create(_globals.core.RAIIEventEmitter.prototype)
525525
WindowPrototype.constructor = exports.Window
526526

527+
var useDevicePixelRatio = function() {
528+
return !!window.cordova
529+
}
530+
527531
WindowPrototype.width = function() {
528-
if (navigator.userAgent.toLocaleLowerCase().match('android')) {
532+
if (useDevicePixelRatio()) {
529533
return Math.floor(this.dom.innerWidth * this.dom.devicePixelRatio);
530534
} else {
531535
return this.dom.innerWidth;
532536
}
533537
}
534538

535539
WindowPrototype.height = function() {
536-
if (navigator.userAgent.toLocaleLowerCase().match('android')) {
540+
if (useDevicePixelRatio()) {
537541
return Math.floor(this.dom.innerHeight * this.dom.devicePixelRatio);
538542
} else {
539543
return this.dom.innerHeight;

0 commit comments

Comments
 (0)