From 7879974cb3dd9e8893cb43475df3041d33047ba5 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Tue, 8 Sep 2020 07:18:20 -0400 Subject: fix device size calculation on start --- www/js/app.js | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index 8b4b3e88..60b1fd30 100755 --- a/www/js/app.js +++ b/www/js/app.js @@ -1151,6 +1151,14 @@ angular.module('zmApp', [ $rootScope.platformOS = "desktop"; NVR.log("Device is ready"); + NVR.log ("setting size"); + $timeout (function () { + + computeDeviceSize(); + + },30); + + //console.log ("*************** PLATFORM IS: "+ionic.Platform.platform()); var ua = navigator.userAgent.toLowerCase(); NVR.debug ("UA is "+ua); @@ -1414,6 +1422,21 @@ angular.module('zmApp', [ }); } + function computeDeviceSize() { + var pixelRatio = window.devicePixelRatio || 1; + $rootScope.pixelRatio = pixelRatio; + $rootScope.devWidth = ((window.innerWidth > 0) ? window.innerWidth : screen.width); + $rootScope.devHeight = ((window.innerHeight > 0) ? window.innerHeight : screen.height); + $rootScope.videoHeight = $rootScope.devHeight - 20; + $rootScope.devWidthIgnorePix = $rootScope.devWidth; + + $rootScope.devWidth *= pixelRatio; + $rootScope.devHeight *= pixelRatio; + + NVR.debug("resize/orient: " + $rootScope.devWidth + "(w) * " + $rootScope.devHeight+"(h)"); + + } + function onOnline() { $timeout(function () { if ($rootScope.online == true) { @@ -1475,18 +1498,7 @@ angular.module('zmApp', [ // give rotation time to actually rotate, or width/height will be bogus $timeout ( function() { - var pixelRatio = window.devicePixelRatio || 1; - $rootScope.pixelRatio = pixelRatio; - $rootScope.devWidth = ((window.innerWidth > 0) ? window.innerWidth : screen.width); - $rootScope.devHeight = ((window.innerHeight > 0) ? window.innerHeight : screen.height); - $rootScope.videoHeight = $rootScope.devHeight - 20; - $rootScope.devWidthIgnorePix = $rootScope.devWidth; - - $rootScope.devWidth *= pixelRatio; - $rootScope.devHeight *= pixelRatio; - - NVR.debug("resize/orient: " + $rootScope.devWidth + "(w) * " + $rootScope.devHeight+"(h)"); - + computeDeviceSize(); $rootScope.$broadcast('sizechanged'); },300); -- cgit v1.2.3