ngx-bootstrap-ci
Version:
Native Angular Bootstrap Components
2 lines • 6.17 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("ngx-bootstrap/utils"),require("@angular/common")):"function"==typeof define&&define.amd?define("ngx-bootstrap/carousel",["exports","@angular/core","ngx-bootstrap/utils","@angular/common"],t):t((e["ngx-bootstrap"]=e["ngx-bootstrap"]||{},e["ngx-bootstrap"].carousel={}),e.ng.core,e.utils,e.ng.common)}(this,function(e,i,n,t){"use strict";var s=function(){function e(){this.interval=5e3,this.noPause=!1,this.noWrap=!1,this.showIndicators=!0}return e.decorators=[{type:i.Injectable}],e}(),r={UNKNOWN:0,NEXT:1,PREV:2};r[r.UNKNOWN]="UNKNOWN",r[r.NEXT]="NEXT",r[r.PREV]="PREV";var o=function(){function e(e,t){this.ngZone=t,this.activeSlideChange=new i.EventEmitter(!1),this._slides=new n.LinkedList,this.destroyed=!1,Object.assign(this,e)}return Object.defineProperty(e.prototype,"activeSlide",{get:function(){return this._currentActiveSlide},set:function(e){this._slides.length&&e!==this._currentActiveSlide&&this._select(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"interval",{get:function(){return this._interval},set:function(e){this._interval=e,this.restartTimer()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"slides",{get:function(){return this._slides.toArray()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isBs4",{get:function(){return!n.isBs3()},enumerable:!0,configurable:!0}),e.prototype.ngOnDestroy=function(){this.destroyed=!0},e.prototype.addSlide=function(e){this._slides.add(e),1===this._slides.length&&(this._currentActiveSlide=void 0,this.activeSlide=0,this.play())},e.prototype.removeSlide=function(e){var t=this,i=this._slides.indexOf(e);if(this._currentActiveSlide===i){var n=void 0;1<this._slides.length&&(n=this.isLast(i)?this.noWrap?i-1:0:i),this._slides.remove(i),setTimeout(function(){t._select(n)},0)}else{this._slides.remove(i);var s=this.getCurrentSlideIndex();setTimeout(function(){t._currentActiveSlide=s,t.activeSlideChange.emit(t._currentActiveSlide)},0)}},e.prototype.nextSlide=function(e){void 0===e&&(e=!1),this.activeSlide=this.findNextSlideIndex(r.NEXT,e)},e.prototype.previousSlide=function(e){void 0===e&&(e=!1),this.activeSlide=this.findNextSlideIndex(r.PREV,e)},e.prototype.selectSlide=function(e){this.activeSlide=e},e.prototype.play=function(){this.isPlaying||(this.isPlaying=!0,this.restartTimer())},e.prototype.pause=function(){this.noPause||(this.isPlaying=!1,this.resetTimer())},e.prototype.getCurrentSlideIndex=function(){return this._slides.findIndex(function(e){return e.active})},e.prototype.isLast=function(e){return e+1>=this._slides.length},e.prototype.findNextSlideIndex=function(e,t){var i=0;if(t||!this.isLast(this.activeSlide)||e===r.PREV||!this.noWrap){switch(e){case r.NEXT:i=this.isLast(this._currentActiveSlide)?!t&&this.noWrap?this._currentActiveSlide:0:this._currentActiveSlide+1;break;case r.PREV:i=0<this._currentActiveSlide?this._currentActiveSlide-1:!t&&this.noWrap?this._currentActiveSlide:this._slides.length-1;break;default:throw new Error("Unknown direction")}return i}},e.prototype._select=function(e){if(isNaN(e))this.pause();else{var t=this._slides.get(this._currentActiveSlide);t&&(t.active=!1);var i=this._slides.get(e);i&&(this._currentActiveSlide=e,i.active=!0,this.activeSlide=e,this.activeSlideChange.emit(e))}},e.prototype.restartTimer=function(){var t=this;this.resetTimer();var e=+this.interval;!isNaN(e)&&0<e&&(this.currentInterval=this.ngZone.runOutsideAngular(function(){return setInterval(function(){var e=+t.interval;t.ngZone.run(function(){t.isPlaying&&!isNaN(t.interval)&&0<e&&t.slides.length?t.nextSlide():t.pause()})},e)}))},e.prototype.resetTimer=function(){this.currentInterval&&(clearInterval(this.currentInterval),this.currentInterval=void 0)},e.decorators=[{type:i.Component,args:[{selector:"carousel",template:'<div (mouseenter)="pause()" (mouseleave)="play()" (mouseup)="play()" class="carousel slide">\n <ol class="carousel-indicators" *ngIf="showIndicators && slides.length > 1">\n <li *ngFor="let slidez of slides; let i = index;" [class.active]="slidez.active === true" (click)="selectSlide(i)"></li>\n </ol>\n <div class="carousel-inner"><ng-content></ng-content></div>\n <a class="left carousel-control carousel-control-prev" [class.disabled]="activeSlide === 0 && noWrap" (click)="previousSlide()" *ngIf="slides.length > 1">\n <span class="icon-prev carousel-control-prev-icon" aria-hidden="true"></span>\n <span *ngIf="isBs4" class="sr-only">Previous</span>\n </a>\n <a class="right carousel-control carousel-control-next" (click)="nextSlide()" [class.disabled]="isLast(activeSlide) && noWrap" *ngIf="slides.length > 1">\n <span class="icon-next carousel-control-next-icon" aria-hidden="true"></span>\n <span class="sr-only">Next</span>\n </a>\n</div>\n'}]}],e.ctorParameters=function(){return[{type:s},{type:i.NgZone}]},e.propDecorators={noWrap:[{type:i.Input}],noPause:[{type:i.Input}],showIndicators:[{type:i.Input}],activeSlideChange:[{type:i.Output}],activeSlide:[{type:i.Input}],interval:[{type:i.Input}]},e}(),a=function(){function e(e){this.addClass=!0,this.carousel=e}return e.prototype.ngOnInit=function(){this.carousel.addSlide(this)},e.prototype.ngOnDestroy=function(){this.carousel.removeSlide(this)},e.decorators=[{type:i.Component,args:[{selector:"slide",template:'\n <div [class.active]="active" class="item">\n <ng-content></ng-content>\n </div>\n ',host:{"[attr.aria-hidden]":"!active"}}]}],e.ctorParameters=function(){return[{type:o}]},e.propDecorators={active:[{type:i.HostBinding,args:["class.active"]},{type:i.Input}],addClass:[{type:i.HostBinding,args:["class.item"]},{type:i.HostBinding,args:["class.carousel-item"]}]},e}(),l=function(){function e(){}return e.forRoot=function(){return{ngModule:e,providers:[]}},e.decorators=[{type:i.NgModule,args:[{imports:[t.CommonModule],declarations:[a,o],exports:[a,o],providers:[s]}]}],e}();e.CarouselComponent=o,e.CarouselModule=l,e.SlideComponent=a,e.CarouselConfig=s,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ngx-bootstrap-carousel.umd.min.js.map