Pinterest like responsive masonry grid system for angular

Angular Core Dependency: >=1.3.0

Module License: MIT

Added by: Sam Deering





Stars: 236

Watchers: 236

Forks: 94

Module Description


Pinterest like responsive masonry grid system for angular

Demo url :


  1. Include angulargrid.js
    <script src="angulargrid.js"></script>
  1. Inject the module on your app
    var App = angular.module('demoApp', ['angularGrid']);
  1. Use directive as attribute defining the model you want to listen
    <ul angular-grid="pics">



    <ul class="dynamic-grid" angular-grid="pics" grid-width="300" gutter-size="10" angular-grid-id="gallery" refresh-on-img-load="false" >
        <li data-ng-repeat="pic in pics" class="grid">
            <img src="{{}}" class="grid-img" data-actual-width = "{{pic.actualWidth}}"  data-actual-height="{{pic.actualHeight}}" />

In above html angular-grid="pics" defines the model you want to listen, so here its listening for pics grid-width, gutter-size and refresh-on-img-load are otional configuration for angular grid.


        position: relative;
        display: none;

        display: block;

    .grid {
        border: 1px solid #cccccc;
        position: absolute;
        list-style: none;
        background: #ffffff;
        box-sizing: border-box;
        -moz-box-sizing : border-box;
        -webkit-transition: all 0.6s ease-out; 
        transition: all 0.6s ease-out; 
    .grid-img {
        width: 100%;
        vertical-align: middle;
        -webkit-transition: opacity 0.6s ease-out;  
        transition: opacity 0.6s ease-out;
        background-color: #fff;
        opacity: 0; 
        visibility: hidden;

        visibility: visible;
        opacity: 1;


angular.module('demoApp', ['angularGrid'])
        this.loadImages = function(){
            return $http.jsonp("");
    .controller('demo', ['$scope','imageService','angularGridInstance', function ($scope,imageService,angularGridInstance) {
                var desc = obj.description,
                    width = desc.match(/width="(.*?)"/)[1],
                    height = desc.match(/height="(.*?)"/)[1];
                obj.actualHeight  = height;
                obj.actualWidth = width;
           $ =;
           $scope.refresh = function(){

##Options (attributes) grid-width : (Default to 250) minimum width in pixel a coloumn can have, coloumn width will increase above grid width depending on container size to make grids responsive.

gutter-size : (Default to 10) Spacing between two column

refresh-on-img-load : (Default to true) refresh the layout on image load so images does not overlap each other

##Handeling Images If your list contains any image inside, as it will load asynchronously, plugin refresh the layout and add following classes to list item and images, so you can handle transitions of image better,

images : image-loading : when an image is loading inside list item image-loaded : when an image is loaded inside list item

list item : image-loading : when any of image is loading inside list item image-loaded : when all images are loaded inside list item

Optionally if you know dimension of images you can add data-actual-width and data-actual-height attributes, so that it will not refresh the layout when those images are loaded.

##Refreshing manually To get the refrence of instance you need to define angular-grid-id on the element which you can get back by injecting angularGridInstance to any controller or directive. Using your id you can refresh your layout ex :;

Module stats last updated: 2017-12-11 16:00:03

Disclaimer: Some data on this page may have been gathered from the authors GitHub respository. If you see any mistakes or outdated information please let us know. Thanks!