ngx-progress-indicator
Version:
A progress indicator library for [Angular](https://angular.io/) apps.
125 lines (118 loc) • 4.97 kB
JavaScript
import * as i0 from '@angular/core';
import { NgModule, Injectable, Optional } from '@angular/core';
import { interval, take } from 'rxjs';
class NgxProgressIndicatorConfig {
}
class NgxProgressIndicatorModule {
static forRoot(config) {
return {
ngModule: NgxProgressIndicatorModule,
providers: [{ provide: NgxProgressIndicatorConfig, useValue: config }],
};
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxProgressIndicatorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: NgxProgressIndicatorModule }); }
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxProgressIndicatorModule }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxProgressIndicatorModule, decorators: [{
type: NgModule,
args: [{
declarations: [],
imports: [],
exports: [],
}]
}] });
const assign = Object.assign;
class NgxProgressIndicatorService {
constructor(rendererFactory, config) {
this.rendererFactory = rendererFactory;
this.renderer = this.rendererFactory.createRenderer(null, null);
this.initialize(config);
}
initialize(config) {
const options = assign({
size: 2,
color: '#0083ff',
className: 'ngx-progress-indicator',
delay: 80,
}, config);
const initialStyle = {
position: 'fixed',
top: 0,
left: 0,
margin: 0,
padding: 0,
border: 'none',
borderRadius: 0,
backgroundColor: config.color,
zIndex: 10000,
height: typeof config.size === 'number' ? config.size + 'px' : config.size,
color: config.color,
opacity: 0,
width: '0%',
};
const startedStyle = {
opacity: 1,
width: '99%',
transition: 'width 10s cubic-bezier(0.1, 0.05, 0, 1)',
};
const finishedStyle = {
opacity: 0,
width: '100%',
transition: 'width 0.1s ease-out, opacity 0.5s ease 0.2s',
};
const glowStyle = {
opacity: 0.4,
boxShadow: '3px 0 8px',
height: '100%',
};
let parent;
this.start = () => {
if (parent && parent.parentNode) {
this.renderer.removeChild(parent.parentNode, parent);
}
parent = this.renderer.createElement('div');
parent.className = options.className + ' stopped';
this.renderer.appendChild(document.body, parent);
assign(parent.style, initialStyle);
let child = this.renderer.createElement('div');
child.className = 'glow';
this.renderer.appendChild(parent, child);
assign(child.style, glowStyle);
interval(options.delay)
.pipe(take(1))
.subscribe({
next: () => {
parent.className = options.className + ' started';
assign(parent.style, startedStyle);
},
});
parent.scrollTop = 0;
};
this.finish = () => {
if (parent) {
parent.className = options.className + ' finished';
assign(parent.style, finishedStyle);
}
};
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxProgressIndicatorService, deps: [{ token: i0.RendererFactory2 }, { token: NgxProgressIndicatorConfig, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxProgressIndicatorService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgxProgressIndicatorService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root',
}]
}], ctorParameters: function () { return [{ type: i0.RendererFactory2 }, { type: NgxProgressIndicatorConfig, decorators: [{
type: Optional
}] }]; } });
/*
* Public API Surface of ngx-progress-indicator
*/
// export * from './lib/ngx-progress-indicator.component';
/**
* Generated bundle index. Do not edit.
*/
export { NgxProgressIndicatorConfig, NgxProgressIndicatorModule, NgxProgressIndicatorService };
//# sourceMappingURL=ngx-progress-indicator.mjs.map