UNPKG

4.4 kBJavaScriptView Raw
1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/animations"),require("@angular/core")):"function"==typeof define&&define.amd?define("ngx-bootstrap/collapse",["exports","@angular/animations","@angular/core"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self)["ngx-bootstrap"]=e["ngx-bootstrap"]||{},e["ngx-bootstrap"].collapse={}),e.ng.animations,e.ng.core)}(this,(function(e,t,i){"use strict";var s="400ms cubic-bezier(0.4,0.0,0.2,1)",n=[t.style({height:0,visibility:"hidden"}),t.animate(s,t.style({height:"*",visibility:"visible"}))],a=[t.style({height:"*",visibility:"visible"}),t.animate(s,t.style({height:0,visibility:"hidden"}))],o=function(){function e(e,t,s){this._el=e,this._renderer=t,this.collapsed=new i.EventEmitter,this.collapses=new i.EventEmitter,this.expanded=new i.EventEmitter,this.expands=new i.EventEmitter,this.isExpanded=!0,this.collapseNewValue=!0,this.isCollapsed=!1,this.isCollapse=!0,this.isCollapsing=!1,this.isAnimated=!1,this._display="block",this._stylesLoaded=!1,this._COLLAPSE_ACTION_NAME="collapse",this._EXPAND_ACTION_NAME="expand",this._factoryCollapseAnimation=s.build(a),this._factoryExpandAnimation=s.build(n)}return Object.defineProperty(e.prototype,"display",{set:function(e){this.isAnimated?(this._display=e,"none"!==e?this.show():this.hide()):this._renderer.setStyle(this._el.nativeElement,"display",e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"collapse",{get:function(){return this.isExpanded},set:function(e){this.collapseNewValue=e,this._player&&!this._isAnimationDone||(this.isExpanded=e,this.toggle())},enumerable:!1,configurable:!0}),e.prototype.ngAfterViewChecked=function(){this._stylesLoaded=!0,this._player&&this._isAnimationDone&&(this._player.reset(),this._renderer.setStyle(this._el.nativeElement,"height","*"))},e.prototype.toggle=function(){this.isExpanded?this.hide():this.show()},e.prototype.hide=function(){var e=this;this.isCollapsing=!0,this.isExpanded=!1,this.isCollapsed=!0,this.isCollapsing=!1,this.collapses.emit(this),this._isAnimationDone=!1,this.animationRun(this.isAnimated,this._COLLAPSE_ACTION_NAME)((function(){e._isAnimationDone=!0,e.collapseNewValue!==e.isCollapsed&&e.isAnimated?e.show():(e.collapsed.emit(e),e._renderer.setStyle(e._el.nativeElement,"display","none"))}))},e.prototype.show=function(){var e=this;this._renderer.setStyle(this._el.nativeElement,"display",this._display),this.isCollapsing=!0,this.isExpanded=!0,this.isCollapsed=!1,this.isCollapsing=!1,this.expands.emit(this),this._isAnimationDone=!1,this.animationRun(this.isAnimated,this._EXPAND_ACTION_NAME)((function(){e._isAnimationDone=!0,e.collapseNewValue!==e.isCollapsed&&e.isAnimated?e.hide():(e.expanded.emit(e),e._renderer.removeStyle(e._el.nativeElement,"overflow"))}))},e.prototype.animationRun=function(e,t){var i=this;if(!e||!this._stylesLoaded)return function(e){return e()};this._renderer.setStyle(this._el.nativeElement,"overflow","hidden"),this._renderer.addClass(this._el.nativeElement,"collapse");var s=t===this._EXPAND_ACTION_NAME?this._factoryExpandAnimation:this._factoryCollapseAnimation;return this._player&&this._player.destroy(),this._player=s.create(this._el.nativeElement),this._player.play(),function(e){var t;return null===(t=i._player)||void 0===t?void 0:t.onDone(e)}},e}();o.decorators=[{type:i.Directive,args:[{selector:"[collapse]",exportAs:"bs-collapse",host:{"[class.collapse]":"true"}}]}],o.ctorParameters=function(){return[{type:i.ElementRef},{type:i.Renderer2},{type:t.AnimationBuilder}]},o.propDecorators={collapsed:[{type:i.Output}],collapses:[{type:i.Output}],expanded:[{type:i.Output}],expands:[{type:i.Output}],isExpanded:[{type:i.HostBinding,args:["class.in"]},{type:i.HostBinding,args:["class.show"]},{type:i.HostBinding,args:["attr.aria-expanded"]}],isCollapsed:[{type:i.HostBinding,args:["attr.aria-hidden"]}],isCollapse:[{type:i.HostBinding,args:["class.collapse"]}],isCollapsing:[{type:i.HostBinding,args:["class.collapsing"]}],display:[{type:i.Input}],isAnimated:[{type:i.Input}],collapse:[{type:i.Input}]};var l=function(){function e(){}return e.forRoot=function(){return{ngModule:e,providers:[]}},e}();l.decorators=[{type:i.NgModule,args:[{declarations:[o],exports:[o]}]}],e.CollapseDirective=o,e.CollapseModule=l,Object.defineProperty(e,"__esModule",{value:!0})}));
2//# sourceMappingURL=ngx-bootstrap-collapse.umd.min.js.map
\No newline at end of file