(function (ns) { /** * @alias app.gallery.Grid */ ns.Grid = function () { this.construct.apply(this, arguments); }; ns.Grid.prototype.construct = function (options) { this.options = $.extend({}, options); this.initListGrid(); }; ns.Grid.prototype.initListGrid = function () { // init Masonry var grid = document.querySelector('.masonry'); var msnry = new Masonry(grid, { itemSelector: '.masonry-item', columnWidth: '.masonry-item-sizer', percentPosition: true, horizontalOrder: true }); imagesLoaded(grid).on('progress', function() { // layout Masonry after each image loads msnry.layout(); }); }; })(qs.defineNS('app.gallery'));