UNPKG

@neocomplexx/ngx-neo-loader

Version:
131 lines (124 loc) 7.92 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('@angular/common')) : typeof define === 'function' && define.amd ? define('@neocomplexx/ngx-neo-loader', ['exports', '@angular/core', 'rxjs', '@angular/common'], factory) : (global = global || self, factory((global.neocomplexx = global.neocomplexx || {}, global.neocomplexx['ngx-neo-loader'] = {}), global.ng.core, global.rxjs, global.ng.common)); }(this, (function (exports, core, rxjs, common) { 'use strict'; var NgxNeoLoaderService = /** @class */ (function () { function NgxNeoLoaderService() { this.DELAY_TIME = 500; this.loaderSubject = new rxjs.Subject(); this.loaderState = this.loaderSubject.asObservable(); } NgxNeoLoaderService.prototype.show = function () { var _this = this; var timerObs = rxjs.timer(this.DELAY_TIME); // subscribing to a observable returns a subscription object var sub = timerObs.subscribe(function (t) { return _this.loaderSubject.next({ showLoading: true }); }); this.sub = sub; return sub; // this.loaderSubject.next(<LoaderState>{showLoading: true}); }; NgxNeoLoaderService.prototype.hide = function (sub) { if (sub === void 0) { sub = null; } if (!sub && this.sub) { this.sub.unsubscribe(); } else if (sub) { sub.unsubscribe(); } this.loaderSubject.next({ showLoading: false }); }; /** @nocollapse */ NgxNeoLoaderService.ɵfac = function NgxNeoLoaderService_Factory(t) { return new (t || NgxNeoLoaderService)(); }; /** @nocollapse */ NgxNeoLoaderService.ɵprov = core.ɵɵdefineInjectable({ token: NgxNeoLoaderService, factory: NgxNeoLoaderService.ɵfac }); return NgxNeoLoaderService; }()); /*@__PURE__*/ (function () { core.ɵsetClassMetadata(NgxNeoLoaderService, [{ type: core.Injectable }], function () { return []; }, null); })(); function LoaderComponent_div_0_Template(rf, ctx) { if (rf & 1) { core.ɵɵelementStart(0, "div"); core.ɵɵelementStart(1, "div", 1); core.ɵɵelementStart(2, "div"); core.ɵɵelementStart(3, "div", 2); core.ɵɵnamespaceSVG(); core.ɵɵelementStart(4, "svg", 3); core.ɵɵelement(5, "circle", 4); core.ɵɵelementEnd(); core.ɵɵelementEnd(); core.ɵɵelementEnd(); core.ɵɵelementEnd(); core.ɵɵelementEnd(); } } var LoaderComponent = /** @class */ (function () { function LoaderComponent(loaderService) { this.loaderService = loaderService; this.show_loading = false; } LoaderComponent.prototype.ngOnInit = function () { var _this = this; this.subscription = this.loaderService.loaderState .subscribe(function (state) { _this.show_loading = state.showLoading; // if (state.showLoading == true){ // this.startLoading(); // } // if (state.showLoading == false){ // this.stopLoading(); // } }); }; LoaderComponent.prototype.ngOnDestroy = function () { this.subscription.unsubscribe(); }; /** @nocollapse */ LoaderComponent.ɵfac = function LoaderComponent_Factory(t) { return new (t || LoaderComponent)(core.ɵɵdirectiveInject(NgxNeoLoaderService)); }; /** @nocollapse */ LoaderComponent.ɵcmp = core.ɵɵdefineComponent({ type: LoaderComponent, selectors: [["neo-app-loader"]], decls: 1, vars: 1, consts: [[4, "ngIf"], [1, "loader-container"], [1, "loader"], ["viewBox", "25 25 50 50", 1, "circular"], ["cx", "50", "cy", "50", "r", "20", "fill", "none", "stroke-width", "2", "stroke-miterlimit", "10", 1, "path"]], template: function LoaderComponent_Template(rf, ctx) { if (rf & 1) { core.ɵɵtemplate(0, LoaderComponent_div_0_Template, 6, 0, "div", 0); } if (rf & 2) { core.ɵɵproperty("ngIf", ctx.show_loading); } }, directives: [common.NgIf], styles: [".loader-container[_ngcontent-%COMP%]{width:100vw!important;height:100vh!important;position:fixed!important;overflow:hidden!important;display:flex!important;z-index:10000!important}.loader-container[_ngcontent-%COMP%] > div[_ngcontent-%COMP%]{margin:auto}.loader[_ngcontent-%COMP%]{position:relative;width:7rem;margin:0 auto .5rem}.loader[_ngcontent-%COMP%]:before{content:\"\";display:block;padding-top:100%}.circular[_ngcontent-%COMP%]{-webkit-animation:2s linear infinite rotate;animation:2s linear infinite rotate;height:100%;transform-origin:center center;width:100%;position:absolute;top:0;bottom:0;left:0;right:0;margin:auto}.path[_ngcontent-%COMP%]{stroke-dasharray:1,200;stroke-dashoffset:0;stroke:rgba(0,0,0,.35)!important;-webkit-animation:1.5s ease-in-out infinite dash;animation:1.5s ease-in-out infinite dash;stroke-linecap:round}@-webkit-keyframes rotate{100%{transform:rotate(360deg)}}@keyframes rotate{100%{transform:rotate(360deg)}}@-webkit-keyframes dash{0%{stroke-dasharray:1,200;stroke-dashoffset:0}50%{stroke-dasharray:89,200;stroke-dashoffset:-35px}100%{stroke-dasharray:89,200;stroke-dashoffset:-124px}}@keyframes dash{0%{stroke-dasharray:1,200;stroke-dashoffset:0}50%{stroke-dasharray:89,200;stroke-dashoffset:-35px}100%{stroke-dasharray:89,200;stroke-dashoffset:-124px}}"] }); return LoaderComponent; }()); /*@__PURE__*/ (function () { core.ɵsetClassMetadata(LoaderComponent, [{ type: core.Component, args: [{ selector: 'neo-app-loader', templateUrl: 'ngx-neo-loader.component.html', styleUrls: ['ngx-neo-loader.component.scss'] }] }], function () { return [{ type: NgxNeoLoaderService }]; }, null); })(); var NgxNeoLoaderModule = /** @class */ (function () { function NgxNeoLoaderModule() { } NgxNeoLoaderModule.forRoot = function () { return { ngModule: NgxNeoLoaderModule, providers: [NgxNeoLoaderService] }; }; /** @nocollapse */ NgxNeoLoaderModule.ɵmod = core.ɵɵdefineNgModule({ type: NgxNeoLoaderModule }); /** @nocollapse */ NgxNeoLoaderModule.ɵinj = core.ɵɵdefineInjector({ factory: function NgxNeoLoaderModule_Factory(t) { return new (t || NgxNeoLoaderModule)(); }, imports: [[ common.CommonModule ]] }); return NgxNeoLoaderModule; }()); (function () { (typeof ngJitMode === "undefined" || ngJitMode) && core.ɵɵsetNgModuleScope(NgxNeoLoaderModule, { declarations: [LoaderComponent], imports: [common.CommonModule], exports: [LoaderComponent] }); })(); /*@__PURE__*/ (function () { core.ɵsetClassMetadata(NgxNeoLoaderModule, [{ type: core.NgModule, args: [{ declarations: [ LoaderComponent ], imports: [ common.CommonModule ], exports: [ LoaderComponent ] }] }], null, null); })(); exports.LoaderComponent = LoaderComponent; exports.NgxNeoLoaderModule = NgxNeoLoaderModule; exports.NgxNeoLoaderService = NgxNeoLoaderService; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=neocomplexx-ngx-neo-loader.umd.js.map