ng-masonry-layout
Version:
Angular Module for displaying a feed of items in a masonry layout using https://github.com/desandro/masonry
2 lines • 3.29 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common")):"function"==typeof define&&define.amd?define("ng-masonry-layout",["exports","@angular/core","@angular/common"],e):e((t=t||self)["ng-masonry-layout"]={},t.ng.core,t.ng.common)}(this,function(t,e,o){"use strict";var n,r=function(){function t(t,o){this.platformId=t,this._element=o,this.useImagesLoaded=!1,this.updateLayout=!1,this.layoutComplete=new e.EventEmitter,this.removeComplete=new e.EventEmitter}return t.prototype.ngOnInit=function(){var t=this;o.isPlatformBrowser(this.platformId)&&n===undefined&&(n=require("masonry-layout")),this.options||(this.options={}),this.options.itemSelector||(this.options.itemSelector="[ngxMasonryItem], ngxMasonryItem"),o.isPlatformBrowser(this.platformId)&&(this._msnry=new n(this._element.nativeElement,this.options),this._msnry.on("layoutComplete",function(e){t.layoutComplete.emit(e)}),this._msnry.on("removeComplete",function(e){t.removeComplete.emit(e)}))},t.prototype.ngOnChanges=function(t){t.updateLayout&&(t.updateLayout.firstChange||this.layout())},t.prototype.ngOnDestroy=function(){this._msnry&&this._msnry.destroy()},t.prototype.layout=function(){var t=this;setTimeout(function(){t._msnry.layout()})},t.prototype.reloadItems=function(){var t=this;setTimeout(function(){t._msnry.reloadItems()})},t.prototype.add=function(t){var e=!1;0===this._msnry.items.length&&(e=!0),this.useImagesLoaded||(this._msnry.appended(t),e&&this.layout())},t.prototype.remove=function(t){this._msnry.remove(t),this.layout()},t.decorators=[{type:e.Component,args:[{selector:"[ngx-masonry], ngx-masonry",template:"<ng-content></ng-content>",styles:["\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t}\n\t"]}]}],t.ctorParameters=function(){return[{type:undefined,decorators:[{type:e.Inject,args:[e.PLATFORM_ID]}]},{type:e.ElementRef}]},t.propDecorators={options:[{type:e.Input}],useImagesLoaded:[{type:e.Input}],updateLayout:[{type:e.Input}],layoutComplete:[{type:e.Output}],removeComplete:[{type:e.Output}]},t}(),s=function(){function t(t,e,o){this._element=t,this._parent=e,this.platformId=o}return t.prototype.ngAfterViewInit=function(){o.isPlatformBrowser(this.platformId)&&(this._parent.add(this._element.nativeElement),this.watchForHtmlChanges())},t.prototype.ngOnDestroy=function(){o.isPlatformBrowser(this.platformId)&&this._parent.remove(this._element.nativeElement)},t.prototype.watchForHtmlChanges=function(){if(MutationObserver=window.MutationObserver||window.WebKitMutationObserver,MutationObserver){var t=this;new MutationObserver(function(e,o){t._parent.layout()}).observe(this._element.nativeElement,{subtree:!0,childList:!0})}},t.decorators=[{type:e.Directive,args:[{selector:"[ngxMasonryItem], ngxMasonryItem"}]}],t.ctorParameters=function(){return[{type:e.ElementRef},{type:r,decorators:[{type:e.Inject,args:[e.forwardRef(function(){return r})]}]},{type:undefined,decorators:[{type:e.Inject,args:[e.PLATFORM_ID]}]}]},t}(),i=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[],declarations:[r,s],exports:[r,s]}]}],t}();t.NgxMasonryComponent=r,t.NgxMasonryDirective=s,t.NgxMasonryModule=i,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=ng-masonry-layout.umd.min.js.map