diff --git a/.gitignore b/.gitignore index 6951c3d..e4452db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ app/ -node_modules/ \ No newline at end of file +node_modules/ +bower_components/ \ No newline at end of file diff --git a/dist/packery.js b/dist/packery.js index bd110f7..5793df9 100644 --- a/dist/packery.js +++ b/dist/packery.js @@ -140,6 +140,19 @@ return obj; }; + this.unpackObject = function (el) { + var promise = service.Packery(self.uniqueId); + + promise.then(function () { + try { + self.packery.remove(el[0]); + $rootScope.$emit('packeryObjectUnPacked', el[0]); + } + catch(err) { + } + }); + }; + this.packObject = function (el) { var promise = service.Packery(self.uniqueId); @@ -201,9 +214,12 @@ scope.rowHeight = scope.rowHeight || config.rowHeight; scope.draggable = scope.draggable || config.draggable; scope.handle = scope.handle || config.handle; + scope.transitionDuration = attrs.transitionduration || "0.4"; // Set global draggability - scope.draggable ? controller.setDraggable(scope.handle) : angular.noop(); + if (scope.draggable==="true") { + controller.setDraggable(scope.handle); + } else { angular.noop();} // Create object for Packery instantiation packeryObj = controller.createAttrObj(scope); @@ -238,7 +254,11 @@ element.css('visibility','hidden'); // Packs individual objects - controller.packObject(element); + controller.packObject(element); + + element.on('$destroy', function() { + controller.unpackObject(element); + }); } }; }; diff --git a/dist/packery.min.js b/dist/packery.min.js index 9e38d3e..843c229 100644 --- a/dist/packery.min.js +++ b/dist/packery.min.js @@ -5,4 +5,4 @@ * License: MIT */ -"use strict";!function(){var a=["packeryTemplates"],b={columnWidth:".packery-sizer",itemSelector:".packery-object",rowHeight:".packery-sizer",draggable:!0,handle:"*",timeout:2e3,acceptedAttributes:["containerStyle","columnWidth","gutter","isHorizontal","isInitLayout","isOriginLeft","isOriginTop","isResizeBound","itemSelector","rowHeight","transitionDuration"]},c=function(a,b,c,d,e){var f,g=[],h=function(a,b){for(var c=0;c",'
','
',""].join("")),a.put("template/packery/packery-object.html",'
')};angular.module("angular-packery",a).constant("packeryConfig",b).service("packeryService",["$rootScope","$q","$interval","$timeout","packeryConfig",c]).controller("PackeryController",["$rootScope","packeryConfig","packeryService",d]).directive("packery",["packeryConfig","packeryService",e]).directive("packeryObject",[f]).directive("packeryObject",[g]),angular.module("packeryTemplates",[]).run(["$templateCache",h])}(); \ No newline at end of file +"use strict";!function(){var a=["packeryTemplates"],b={columnWidth:".packery-sizer",itemSelector:".packery-object",rowHeight:".packery-sizer",draggable:!0,handle:"*",timeout:2e3,acceptedAttributes:["containerStyle","columnWidth","gutter","isHorizontal","isInitLayout","isOriginLeft","isOriginTop","isResizeBound","itemSelector","rowHeight","transitionDuration"]},c=function(a,b,c,d,e){var f,g=[],h=function(a,b){for(var c=0;c",'
','
',""].join("")),a.put("template/packery/packery-object.html",'
')};angular.module("angular-packery",a).constant("packeryConfig",b).service("packeryService",["$rootScope","$q","$interval","$timeout","packeryConfig",c]).controller("PackeryController",["$rootScope","packeryConfig","packeryService",d]).directive("packery",["packeryConfig","packeryService",e]).directive("packeryObject",[f]).directive("packeryObject",[g]),angular.module("packeryTemplates",[]).run(["$templateCache",h])}(); \ No newline at end of file diff --git a/src/packery.js b/src/packery.js index 5871c47..db22834 100644 --- a/src/packery.js +++ b/src/packery.js @@ -133,6 +133,19 @@ return obj; }; + this.unpackObject = function (el) { + var promise = service.Packery(self.uniqueId); + + promise.then(function () { + try { + self.packery.remove(el[0]); + $rootScope.$emit('packeryObjectUnPacked', el[0]); + } + catch(err) { + } + }); + }; + this.packObject = function (el) { var promise = service.Packery(self.uniqueId); @@ -194,9 +207,12 @@ scope.rowHeight = scope.rowHeight || config.rowHeight; scope.draggable = scope.draggable || config.draggable; scope.handle = scope.handle || config.handle; + scope.transitionDuration = attrs.transitionduration || "0.4"; // Set global draggability - scope.draggable ? controller.setDraggable(scope.handle) : angular.noop(); + if (scope.draggable==="true") { + controller.setDraggable(scope.handle); + } else { angular.noop();} // Create object for Packery instantiation packeryObj = controller.createAttrObj(scope); @@ -231,7 +247,11 @@ element.css('visibility','hidden'); // Packs individual objects - controller.packObject(element); + controller.packObject(element); + + element.on('$destroy', function() { + controller.unpackObject(element); + }); } }; };