diff options
| -rw-r--r-- | www/external/packery.pkgd.js | 5 | ||||
| -rw-r--r-- | www/js/MontageCtrl.js | 40 | ||||
| -rw-r--r-- | www/js/MontageHistoryCtrl2.js | 3 |
3 files changed, 30 insertions, 18 deletions
diff --git a/www/external/packery.pkgd.js b/www/external/packery.pkgd.js index 66c3b21f..86cb6932 100644 --- a/www/external/packery.pkgd.js +++ b/www/external/packery.pkgd.js @@ -2748,6 +2748,7 @@ Packery.prototype.getShiftPositions = function( attrName ) { attrName = attrName || 'id'; var _this = this; return this.items.map( function( item ) { + //console.log ("x for "+item.element.getAttribute(attrName)+" is " + item.rect.x); return { attr: item.element.getAttribute( attrName ), size: item.element.getAttribute ("data-item-size"), @@ -2796,8 +2797,10 @@ Packery.prototype.initShiftLayout = function( positions, attr ) { var selector = '[' + attr + '="' + itemPosition.attr + '"]' var itemElem = this.element.querySelector( selector ); var item = this.getItem( itemElem ); - item.rect.x = itemPosition.x * this.packer.width; + //item.rect.x = itemPosition.x * this.packer.width; + item.rect.x = Math.ceil(itemPosition.x * this.packer.width); item.rect.y = itemPosition.y * this.packer.height; + //console.log ("X computed as " + item.rect.x); return item; }, this ); this.shiftLayout(); diff --git a/www/js/MontageCtrl.js b/www/js/MontageCtrl.js index db4391d1..38e1d1a0 100644 --- a/www/js/MontageCtrl.js +++ b/www/js/MontageCtrl.js @@ -129,6 +129,7 @@ angular.module('zmApp.controllers') //console.log ("POSITION STR IS " + positionsStr); positions = JSON.parse(positionsStr); NVRDataModel.log("found a packery layout"); + layouttype = false; } @@ -167,7 +168,7 @@ angular.module('zmApp.controllers') imagesLoaded(elem).on('always', function () { //console.log ("******** ALL IMAGES LOADED"); NVRDataModel.debug("All images loaded"); - $scope.allImagesLoaded = true; + $ionicLoading.hide(); @@ -181,12 +182,13 @@ angular.module('zmApp.controllers') }); if (!progressCalled) { NVRDataModel.log("*** BUG PROGRESS WAS NOT CALLED"); - pckry.reloadItems(); - } - + NVRDataModel.debug("All images loaded, doing image layout"); $timeout(function () { - + pckry.initShiftLayout(positions, 'data-item-id'); + //pckry.reloadItems(); + + pckry.getItemElements().forEach(function (itemElem) { draggie = new Draggabilly(itemElem); pckry.bindDraggabillyEvents(draggie); @@ -214,15 +216,12 @@ angular.module('zmApp.controllers') } - NVRDataModel.debug("All images loaded, doing image layout"); - $timeout(function () { - pckry.initShiftLayout(positions, 'data-item-id'); - }, 0); + } - $timeout(function () { - NVRDataModel.log("Force calling resize"); - pckry.shiftLayout(); - }, zm.packeryTimer); // don't ask + + $scope.allImagesLoaded = true; + $timeout (function () { + pckry.layout();},300); @@ -242,6 +241,7 @@ angular.module('zmApp.controllers') //console.log ("POSITIONS MAP " + JSON.stringify(positions)); var ld = NVRDataModel.getLogin(); ld.packeryPositions = JSON.stringify(positions); + //console.log ("Saving " + ld.packeryPositions); NVRDataModel.setLogin(ld); } @@ -407,6 +407,7 @@ angular.module('zmApp.controllers') NVRDataModel.debug("POSITIONS MAP " + JSON.stringify(positions)); var ld = NVRDataModel.getLogin(); ld.packeryPositions = JSON.stringify(positions); + //console.log ("Saving " + ld.packeryPositions); NVRDataModel.setLogin(ld); }); }); @@ -637,6 +638,7 @@ angular.module('zmApp.controllers') //console.log ("POSITIONS MAP " + JSON.stringify(positions)); var ld = NVRDataModel.getLogin(); ld.packeryPositions = JSON.stringify(positions); + //console.log ("Saving " + ld.packeryPositions); NVRDataModel.setLogin(ld); }, 300); }, 100); @@ -823,7 +825,7 @@ angular.module('zmApp.controllers') function orientationChanged() { NVRDataModel.debug("Detected orientation change, redoing packery resize"); $timeout(function () { - pckry.onresize(); + if (pckry) pckry.onresize(); }); } @@ -851,7 +853,7 @@ angular.module('zmApp.controllers') NVRDataModel.debug("Setting image mode to snapshot, will change to image when packery is all done"); $scope.allImagesLoaded = false; $scope.isDragabillyOn = false; - $scope.allImagesLoaded = false; + $scope.gridScale = "grid-item-50"; $scope.LoginData = NVRDataModel.getLogin(); //FIXME @@ -1036,7 +1038,9 @@ angular.module('zmApp.controllers') var positions = pckry.getShiftPositions('data-item-id'); //console.log ("POSITIONS MAP " + JSON.stringify(positions)); var ld = NVRDataModel.getLogin(); + ld.packeryPositions = JSON.stringify(positions); + //console.log ("Saving " + ld.packeryPositions); NVRDataModel.setLogin(ld); // $scope.slider.monsize = 2; }); @@ -1070,6 +1074,8 @@ angular.module('zmApp.controllers') // return; } + + $scope.sliderChanging = true; var somethingReset = false; @@ -1111,14 +1117,16 @@ angular.module('zmApp.controllers') } - //pckry.reloadItems(); + pckry.shiftLayout(); pckry.once('layoutComplete', function () { $timeout(function () { var positions = pckry.getShiftPositions('data-item-id'); //console.log ("POSITIONS MAP " + JSON.stringify(positions)); var ld = NVRDataModel.getLogin(); + ld.packeryPositions = JSON.stringify(positions); + //console.log ("Saving " + ld.packeryPositions); NVRDataModel.setLogin(ld); $ionicLoading.hide(); $scope.sliderChanging = false; diff --git a/www/js/MontageHistoryCtrl2.js b/www/js/MontageHistoryCtrl2.js index d9107a0f..cf621f9f 100644 --- a/www/js/MontageHistoryCtrl2.js +++ b/www/js/MontageHistoryCtrl2.js @@ -1283,7 +1283,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc imagesLoaded(elem).once('always', function () { console.log("******** ALL IMAGES LOADED"); NVRDataModel.debug("All images loaded"); - $scope.allImagesLoaded = true; + $ionicLoading.hide(); @@ -1340,6 +1340,7 @@ angular.module('zmApp.controllers').controller('zmApp.MontageHistoryCtrl', ['$sc $timeout(function () { NVRDataModel.log("Force calling resize"); pckry.layout(); + $scope.allImagesLoaded = true; }, zm.packeryTimer); // don't ask |
