angular-masonry
Advanced tools
Comparing version 0.11.1 to 0.12.0
/*! | ||
* angular-masonry 0.11.0 | ||
* angular-masonry 0.11.1 | ||
* Pascal Hartig, weluse GmbH, http://weluse.de/ | ||
@@ -99,3 +99,3 @@ * License: MIT | ||
$scope.$emit('masonry.destroyed'); | ||
bricks = []; | ||
bricks = {}; | ||
}; | ||
@@ -119,2 +119,3 @@ this.reload = function reload() { | ||
element.masonry(options); | ||
scope.masonryContainer = element[0]; | ||
var loadImages = scope.$eval(attrs.loadImages); | ||
@@ -134,2 +135,10 @@ ctrl.loadImages = loadImages !== false; | ||
} | ||
var reloadOnResize = scope.$eval(attrs.reloadOnResize); | ||
if (reloadOnResize !== false && attrs.reloadOnResize !== undefined) { | ||
scope.$watch('masonryContainer.offsetWidth', function (newWidth, oldWidth) { | ||
if (newWidth != oldWidth) { | ||
ctrl.reload(); | ||
} | ||
}); | ||
} | ||
scope.$emit('masonry.created', element); | ||
@@ -136,0 +145,0 @@ scope.$on('$destroy', ctrl.destroy); |
/*! | ||
* angular-masonry 0.11.0 | ||
* angular-masonry 0.11.1 | ||
* Pascal Hartig, weluse GmbH, http://weluse.de/ | ||
* License: MIT | ||
*/ | ||
!function(){"use strict";angular.module("wu.masonry",[]).controller("MasonryCtrl",["$scope","$element","$timeout",function(a,b,c){function d(a){a.addClass("loaded")}var e={},f=[],g=!1,h=this,i=null;this.preserveOrder=!1,this.loadImages=!0,this.scheduleMasonryOnce=function(){var a=arguments,b=f.filter(function(b){return b[0]===a[0]}).length>0;b||this.scheduleMasonry.apply(null,arguments)},this.scheduleMasonry=function(){i&&c.cancel(i),f.push([].slice.call(arguments)),i=c(function(){g||(f.forEach(function(a){b.masonry.apply(b,a)}),f=[])},30)},this.appendBrick=function(a,c){function f(){0===Object.keys(e).length&&b.masonry("resize"),void 0===e[c]&&(e[c]=!0,d(a),b.masonry("appended",a,!0))}function i(){h.scheduleMasonryOnce("layout")}g||(h.loadImages?h.preserveOrder?(f(),a.imagesLoaded(i)):a.imagesLoaded(function(){f(),i()}):(f(),i()))},this.removeBrick=function(a,c){g||(delete e[a],b.masonry("remove",c),this.scheduleMasonryOnce("layout"))},this.destroy=function(){g=!0,b.data("masonry")&&b.masonry("destroy"),a.$emit("masonry.destroyed"),e=[]},this.reload=function(){b.masonry(),a.$emit("masonry.reloaded")}}]).directive("masonry",function(){return{restrict:"AE",controller:"MasonryCtrl",link:{pre:function(a,b,c,d){var e=a.$eval(c.masonry||c.masonryOptions),f=angular.extend({itemSelector:c.itemSelector||".masonry-brick",columnWidth:parseInt(c.columnWidth,10)||c.columnWidth},e||{});b.masonry(f);var g=a.$eval(c.loadImages);d.loadImages=g!==!1;var h=a.$eval(c.preserveOrder);d.preserveOrder=h!==!1&&void 0!==c.preserveOrder;var i=a.$eval(c.reloadOnShow);i!==!1&&void 0!==c.reloadOnShow&&a.$watch(function(){return b.prop("offsetParent")},function(a,b){a&&!b&&d.reload()}),a.$emit("masonry.created",b),a.$on("$destroy",d.destroy)}}}}).directive("masonryBrick",function(){return{restrict:"AC",require:"^masonry",scope:!0,link:{pre:function(a,b,c,d){var e,f=a.$id;d.appendBrick(b,f),b.on("$destroy",function(){d.removeBrick(f,b)}),a.$on("masonry.reload",function(){d.scheduleMasonryOnce("reloadItems"),d.scheduleMasonryOnce("layout")}),a.$watch("$index",function(){void 0!==e&&e!==a.$index&&(d.scheduleMasonryOnce("reloadItems"),d.scheduleMasonryOnce("layout")),e=a.$index})}}}})}(); | ||
!function(){"use strict";angular.module("wu.masonry",[]).controller("MasonryCtrl",["$scope","$element","$timeout",function(a,b,c){function d(a){a.addClass("loaded")}var e={},f=[],g=!1,h=this,i=null;this.preserveOrder=!1,this.loadImages=!0,this.scheduleMasonryOnce=function(){var a=arguments,b=f.filter(function(b){return b[0]===a[0]}).length>0;b||this.scheduleMasonry.apply(null,arguments)},this.scheduleMasonry=function(){i&&c.cancel(i),f.push([].slice.call(arguments)),i=c(function(){g||(f.forEach(function(a){b.masonry.apply(b,a)}),f=[])},30)},this.appendBrick=function(a,c){function f(){0===Object.keys(e).length&&b.masonry("resize"),void 0===e[c]&&(e[c]=!0,d(a),b.masonry("appended",a,!0))}function i(){h.scheduleMasonryOnce("layout")}g||(h.loadImages?h.preserveOrder?(f(),a.imagesLoaded(i)):a.imagesLoaded(function(){f(),i()}):(f(),i()))},this.removeBrick=function(a,c){g||(delete e[a],b.masonry("remove",c),this.scheduleMasonryOnce("layout"))},this.destroy=function(){g=!0,b.data("masonry")&&b.masonry("destroy"),a.$emit("masonry.destroyed"),e={}},this.reload=function(){b.masonry(),a.$emit("masonry.reloaded")}}]).directive("masonry",function(){return{restrict:"AE",controller:"MasonryCtrl",link:{pre:function(a,b,c,d){var e=a.$eval(c.masonry||c.masonryOptions),f=angular.extend({itemSelector:c.itemSelector||".masonry-brick",columnWidth:parseInt(c.columnWidth,10)||c.columnWidth},e||{});b.masonry(f),a.masonryContainer=b[0];var g=a.$eval(c.loadImages);d.loadImages=g!==!1;var h=a.$eval(c.preserveOrder);d.preserveOrder=h!==!1&&void 0!==c.preserveOrder;var i=a.$eval(c.reloadOnShow);i!==!1&&void 0!==c.reloadOnShow&&a.$watch(function(){return b.prop("offsetParent")},function(a,b){a&&!b&&d.reload()});var j=a.$eval(c.reloadOnResize);j!==!1&&void 0!==c.reloadOnResize&&a.$watch("masonryContainer.offsetWidth",function(a,b){a!=b&&d.reload()}),a.$emit("masonry.created",b),a.$on("$destroy",d.destroy)}}}}).directive("masonryBrick",function(){return{restrict:"AC",require:"^masonry",scope:!0,link:{pre:function(a,b,c,d){var e,f=a.$id;d.appendBrick(b,f),b.on("$destroy",function(){d.removeBrick(f,b)}),a.$on("masonry.reload",function(){d.scheduleMasonryOnce("reloadItems"),d.scheduleMasonryOnce("layout")}),a.$watch("$index",function(){void 0!==e&&e!==a.$index&&(d.scheduleMasonryOnce("reloadItems"),d.scheduleMasonryOnce("layout")),e=a.$index})}}}})}(); |
{ | ||
"name": "angular-masonry", | ||
"description": "An AngularJS directive for Masonry.", | ||
"version": "0.11.1", | ||
"version": "0.12.0", | ||
"main": "./angular-masonry.js", | ||
@@ -20,3 +20,3 @@ "ignore": [ | ||
"masonry": "~3.2.0", | ||
"angular": "~1.3.0", | ||
"angular": "^1.3.0", | ||
"jquery": "~2.1.0", | ||
@@ -27,3 +27,3 @@ "imagesloaded": "~3.1.0", | ||
"devDependencies": { | ||
"angular-mocks": "~1.3.0", | ||
"angular-mocks": "^1.3.0", | ||
"sinonjs": "~1.10.0", | ||
@@ -30,0 +30,0 @@ "jasmine-sinon": "~0.4.0" |
@@ -0,1 +1,16 @@ | ||
<a name="0.12.0"></a> | ||
# [0.12.0](https://github.com/passy/angular-masonry/compare/v0.11.1...v0.12.0) (2015-09-09) | ||
### Bug Fixes | ||
* **test:** make reload-on-resize tests more specific ([bf280d0](https://github.com/passy/angular-masonry/commit/bf280d0)) | ||
### Features | ||
* **bower:** make the module compatible with angular 1.4 ([38c9fee](https://github.com/passy/angular-masonry/commit/38c9fee)) | ||
* **directive:** add `reload-on-resize` option ([6065e18](https://github.com/passy/angular-masonry/commit/6065e18)) | ||
<a name="0.11.1"></a> | ||
@@ -2,0 +17,0 @@ ### 0.11.1 (2015-06-18) |
@@ -71,3 +71,13 @@ module.exports = function (grunt) { | ||
}, | ||
changelog: {}, | ||
conventionalChangelog: { | ||
options: { | ||
changelogOpts: { | ||
// conventional-changelog options go here | ||
preset: 'angular' | ||
}, | ||
}, | ||
release: { | ||
src: 'CHANGELOG.md' | ||
} | ||
}, | ||
ngmin: { | ||
@@ -74,0 +84,0 @@ dist: { |
{ | ||
"name": "angular-masonry", | ||
"version": "0.11.1", | ||
"version": "0.12.0", | ||
"main": "angular-masonry.js", | ||
"devDependencies": { | ||
"grunt": "~0.4.1", | ||
"grunt-cli": "^0.1.13", | ||
"grunt-contrib-concat": "^0.5.1", | ||
@@ -11,3 +12,3 @@ "grunt-contrib-connect": "^0.11.2", | ||
"grunt-contrib-watch": "^0.6.1", | ||
"grunt-conventional-changelog": "^3.0.0", | ||
"grunt-conventional-changelog": "^4.1.0", | ||
"grunt-karma": "^0.12.0", | ||
@@ -14,0 +15,0 @@ "grunt-ngmin": "0.0.3", |
@@ -121,2 +121,20 @@ # AngularJS Masonry Directive [![Build Status](https://travis-ci.org/passy/angular-masonry.png)](https://travis-ci.org/passy/angular-masonry) [![Dependency Status](https://gemnasium.com/passy/angular-masonry.png)](https://gemnasium.com/passy/angular-masonry) [![Code Climate](https://codeclimate.com/github/passy/angular-masonry.png)](https://codeclimate.com/github/passy/angular-masonry) | ||
### `reload-on-resize` | ||
The `reload-on-resize` attribute triggers a reload when the masonry element changes | ||
its width, useful when only the parent element is resized (and not the window) and | ||
you want the elements to be rearranged. Without this if the parent is resized then | ||
some blank space may be left on the sides. | ||
*Example:* | ||
```html | ||
<masonry reload-on-resize> | ||
<div class="masonry-brick">...</div> | ||
<div class="masonry-brick">...</div> | ||
</masonry> | ||
``` | ||
### `masonry-options` | ||
@@ -123,0 +141,0 @@ |
@@ -134,6 +134,7 @@ /*! | ||
element.masonry(options); | ||
scope.masonryContainer = element[0]; | ||
var loadImages = scope.$eval(attrs.loadImages); | ||
ctrl.loadImages = loadImages !== false; | ||
var preserveOrder = scope.$eval(attrs.preserveOrder); | ||
ctrl.preserveOrder = (preserveOrder !== false && attrs.preserveOrder !== undefined); | ||
ctrl.preserveOrder = (preserveOrder !== false && attrs.preserveOrder !== undefined); | ||
var reloadOnShow = scope.$eval(attrs.reloadOnShow); | ||
@@ -149,2 +150,10 @@ if (reloadOnShow !== false && attrs.reloadOnShow !== undefined) { | ||
} | ||
var reloadOnResize = scope.$eval(attrs.reloadOnResize); | ||
if (reloadOnResize !== false && attrs.reloadOnResize !== undefined) { | ||
scope.$watch('masonryContainer.offsetWidth', function (newWidth, oldWidth) { | ||
if (newWidth != oldWidth) { | ||
ctrl.reload(); | ||
} | ||
}); | ||
} | ||
@@ -151,0 +160,0 @@ scope.$emit('masonry.created', element); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45692
506
178
15