From a18aa84429258413b0e7adcd6c211f243ebefcf2 Mon Sep 17 00:00:00 2001 From: Pliable Pixels Date: Fri, 21 Dec 2018 10:24:05 -0500 Subject: #766 - wait for rotation to complete or width/height will be wrong --- www/js/EventCtrl.js | 36 ++++++++++++++++++++---------------- www/js/EventModalCtrl.js | 5 +++-- www/js/MonitorModalCtrl.js | 15 --------------- www/js/MontageCtrl.js | 9 ++------- www/js/MontageHistoryCtrl.js | 13 ++----------- www/js/app.js | 9 ++++++++- www/templates/events-modal.html | 6 ++++-- 7 files changed, 39 insertions(+), 54 deletions(-) (limited to 'www') diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js index b3741489..70883b29 100644 --- a/www/js/EventCtrl.js +++ b/www/js/EventCtrl.js @@ -2823,23 +2823,27 @@ angular.module('zmApp.controllers') function recomputeThumbSize() { // NVRDataModel.debug("EventCtrl: recompute thumbnails"); - for (var i = 0; i < $scope.events.length; i++) { - var tempMon = NVRDataModel.getMonitorObject($scope.events[i].Event.MonitorId); - if (tempMon != undefined) { - - var mw = parseInt(tempMon.Monitor.Width); - var mh = parseInt(tempMon.Monitor.Height); - var mo = parseInt(tempMon.Monitor.Orientation); - - var th = computeThumbnailSize(mw, mh, mo); - $scope.events[i].Event.thumbWidth = th.w; - $scope.events[i].Event.thumbHeight = th.h; - //console.log ("Setting to "+th.w+"*"+th.h); - + // remember, devHeight/devWidth upate 300ms after rotation + $timeout ( function () { + for (var i = 0; i < $scope.events.length; i++) { + var tempMon = NVRDataModel.getMonitorObject($scope.events[i].Event.MonitorId); + if (tempMon != undefined) { + + var mw = parseInt(tempMon.Monitor.Width); + var mh = parseInt(tempMon.Monitor.Height); + var mo = parseInt(tempMon.Monitor.Orientation); + + var th = computeThumbnailSize(mw, mh, mo); + $scope.events[i].Event.thumbWidth = th.w; + $scope.events[i].Event.thumbHeight = th.h; + //console.log ("Setting to "+th.w+"*"+th.h); + + } + + } - - - } + },500); + } diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index 50da86d4..ce39e827 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -1124,9 +1124,9 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $ionicLoading.hide(); if (m.id != 'footage') - return; + $ionicSideMenuDelegate.canDragContent(false); showLive = true; if (m.snapshot == 'enabled') { @@ -1295,6 +1295,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.$on('modal.removed', function (e, m) { + $ionicSideMenuDelegate.canDragContent(true); if ($rootScope.platformOS == 'desktop') { NVRDataModel.debug("Removing keyboard handler"); window.removeEventListener('keydown', keyboardHandler, true); @@ -2069,7 +2070,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro autoPlay: true, responsive: false, nativeControls: false, - nativeFullScreen: false, + nativeFullScreen: true, playsInline: true, sources: [{ diff --git a/www/js/MonitorModalCtrl.js b/www/js/MonitorModalCtrl.js index ced3dfe8..41eac0ed 100644 --- a/www/js/MonitorModalCtrl.js +++ b/www/js/MonitorModalCtrl.js @@ -27,20 +27,6 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ $scope.csize = ($rootScope.platformOS == 'desktop') ? 10 : 20; - window.addEventListener("resize", imageLoaded, false); - - - //$rootScope.authSession = "undefined"; - - /* $ionicLoading.show({ - template: $translate.instant('kNegotiatingStreamAuth') + '...', - animation: 'fade-in', - showBackdrop: false, - duration: zm.loadingTimeout, - maxWidth: 300, - showDelay: 0 - });*/ - $scope.currentStreamMode = 'single'; NVRDataModel.log("Using stream mode " + $scope.currentStreamMode); @@ -1367,7 +1353,6 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ $scope.$on('modal.removed', function () { - window.removeEventListener("resize", imageLoaded, false); if ($rootScope.platformOS == 'android') { NVRDataModel.debug("Deregistering handlers for multi-window"); diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index 5ec2ed41..f7944ebb 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -1444,11 +1444,7 @@ angular.module('zmApp.controllers') if ($scope.modal) $scope.modal.remove(); }); - function orientationChanged() { - - } - - + // remove a saved montage profile $scope.deleteMontageProfile = function () { var posArray; @@ -2023,8 +2019,7 @@ angular.module('zmApp.controllers') initPackery(); }, zm.packeryTimer); //console.log("**VIEW ** Montage Ctrl AFTER ENTER"); - window.addEventListener("resize", orientationChanged, false); - + if ($rootScope.platformOS != 'android') { document.addEventListener("pause", onPause, false); } else { diff --git a/www/js/MontageHistoryCtrl.js b/www/js/MontageHistoryCtrl.js index a83d2ae3..1faf41dd 100644 --- a/www/js/MontageHistoryCtrl.js +++ b/www/js/MontageHistoryCtrl.js @@ -69,12 +69,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc timefrom.toDate(); }; - function orientationChanged() { - // NVRDataModel.debug("Detected orientation change, redoing packery resize"); - /* $timeout(function () { - pckry.onresize(); - });*/ - } + //-------------------------------------- // pause/unpause nph-zms //--------------------------------------- @@ -864,10 +859,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc // make sure this is applied in scope digest to stop network pull // thats why we are doing it beforeLeave pckry.destroy(); - window.removeEventListener("resize", orientationChanged, false); - //NVRDataModel.log("Forcing a window.stop() here"); - //NVRDataModel.stopNetwork("MontageHistory-beforeLeave"); - + }); $scope.$on('$ionicView.unloaded', function () {}); $scope.sliderChanged = function (dirn) { @@ -1294,7 +1286,6 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $scope.isModalActive = false; $scope.hrsAgo = 4; - window.addEventListener("resize", orientationChanged, false); document.addEventListener("pause", onPause, false); document.addEventListener("resume", onResume, false); diff --git a/www/js/app.js b/www/js/app.js index 6e400e94..f00bca93 100755 --- a/www/js/app.js +++ b/www/js/app.js @@ -1727,11 +1727,18 @@ angular.module('zmApp', [ // http://stackoverflow.com/questions/1649086/detect-rotation-of-android-phone-in-the-browser-with-javascript var checkOrientation = function () { + + // 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); - //console.log("********NEW Computed Dev Width & Height as" + $rootScope.devWidth + "*" + $rootScope.devHeight); + + // console.log("********NEW Computed Dev Width & Height as" + $rootScope.devWidth + "*" + $rootScope.devHeight); + },300); + }; diff --git a/www/templates/events-modal.html b/www/templates/events-modal.html index 99994380..d9f2d5d6 100644 --- a/www/templates/events-modal.html +++ b/www/templates/events-modal.html @@ -63,8 +63,10 @@
- -
+ + + +