diff options
| -rw-r--r-- | www/js/EventCtrl.js | 67 |
1 files changed, 28 insertions, 39 deletions
diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js index 144f4380..a3f86425 100644 --- a/www/js/EventCtrl.js +++ b/www/js/EventCtrl.js @@ -85,15 +85,12 @@ angular.module('zmApp.controllers') $scope.$on('sizechanged', function() { - //recomputeRowHeights(); - //recomputeThumbSize(); - $scope.$apply(); + recomputeRowHeights(); $ionicScrollDelegate.resize(); - // $scope.eventsBeingLoaded = true; $timeout (function() { navTitle(); },300); - + }); function getRowHeight(event) { @@ -258,26 +255,42 @@ angular.module('zmApp.controllers') NVR.computeDeviceSize(); }); - - function recomputeRowHeights() { - NVR.debug ("recomputing row height"); + function switchThumbClass() { + var ld = NVR.getLogin(); if (ld.eventViewThumbs != 'none') { if (ld.eventViewThumbsSize == 'large') { - NVR.debug ('Switching to big thumbs style'); + NVR.debug ('Using big thumbs'); $scope.thumbClass = 'large'; } else if (ld.eventViewThumbsSize == 'small') { - NVR.debug ('Switching to small thumbs style'); + NVR.debug ('Using small thumbs '); $scope.thumbClass = 'small'; } else { - NVR.debug ('using xsmall thumbs style'); + NVR.debug ('using xsmall thumbs '); $scope.thumbClass = 'xsmall'; } } else { NVR.debug ('No thumbs'); } - + + } + + function recomputeRowHeights() { + switchThumbClass(); + $scope.eventsBeingLoaded = true; + $timeout (function() { + NVR.debug ("recomputing all row heights"); + for (var i = 0; i < $scope.events.length; i++) { + $scope.events[i].Event.rowHeight = getRowHeight($scope.events[i]); + } + },10); + + NVR.debug ('giving time for collection to redraw...'); + $scope.eventsBeingLoaded = false; + $timeout(function() { + NVR.debug ('ready for next resize'); + },300); } @@ -297,8 +310,9 @@ angular.module('zmApp.controllers') The max size of the image is in computeThumbnailSize() */ + var ld = NVR.getLogin(); - recomputeRowHeights(); + switchThumbClass(); $scope.mid = ''; if (ld.eventViewThumbs != 'objdetect_gif') { maxEventsToLoad = 50; @@ -3277,32 +3291,7 @@ angular.module('zmApp.controllers') } - function recomputeThumbSize() { - // NVR.debug("EventCtrl: recompute thumbnails"); - NVR.debug ("recompute thumbs size"); - // remember, devHeight/devWidth upate 300ms after rotation - for (var i = 0; i < $scope.events.length; i++) { - var tempMon = NVR.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); - - // eventHeight = document.getElementById('item-0').offsetHeight; - - } - - - } - - - } + function calculateAspectRatioFit(srcWidth, srcHeight, maxWidth, maxHeight) { // credit: https://stackoverflow.com/a/14731922 |
