UNPKG

ngx-i24-colored-lights

Version:

A lightweight plugin to render a simple, animated colored lighted cover.

122 lines (115 loc) 7.66 kB
import * as i0 from '@angular/core'; import { Injectable, Component, ViewEncapsulation, Input, NgModule } from '@angular/core'; import * as i1 from '@angular/common'; import { CommonModule } from '@angular/common'; class NgxI24ColoredLightsService { constructor() { } } NgxI24ColoredLightsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxI24ColoredLightsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); NgxI24ColoredLightsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxI24ColoredLightsService, providedIn: 'root' }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxI24ColoredLightsService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: function () { return []; } }); class NgxI24ColoredLightsComponent { constructor() { this._BG = 'linear-gradient(#0A0707 0%, #110C0D 50%, #0C090A 100%)'; this.colorCollection = ['#D00010', '#FEC641', '#63C13B', '#FE0016', '#5C6C94', '#6B0D05', '#7D0006', '#DB1913', '#FEE34A', '#2F8A2']; this.lightsCount = 100; this.textColor = '#FFFFFF'; this.lightSize = 75; this.blurLevel = 3; this.title = "Happy Birthday"; this.imageUrl = ''; this.totalAnimation = 10; this.maxDelay = 5; this.minDuration = 5; this.maxDuration = 25; this.sizeVariety = 0.25; this.list = []; } ngOnInit() { this.initLights(); } ngAfterViewInit() { } random(n) { return Math.floor(Math.random() * n) + 1; } initLights() { for (let index = 1; index < this.lightsCount; index++) { this.list.push({ width: this.lightSize + this.random(this.sizeVariety * this.lightSize), vertical: this.random(100), horizontal: this.random(100), blur: this.blurLevel + this.random(this.blurLevel), delay: this.random(this.maxDelay), animation: this.random(this.totalAnimation), duration: this.minDuration + this.random(this.maxDuration), color: this.colorCollection[this.random(this.colorCollection.length) - 1], }); } if (this.imageUrl === '') { this.imageUrl = this._BG; } else { this.imageUrl = 'url(' + this.imageUrl + ')'; } } } NgxI24ColoredLightsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxI24ColoredLightsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); NgxI24ColoredLightsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: NgxI24ColoredLightsComponent, selector: "i24-colored-lights", inputs: { colorCollection: "colorCollection", lightsCount: "lightsCount", textColor: "textColor", lightSize: "lightSize", blurLevel: "blurLevel", title: "title", imageUrl: "imageUrl" }, ngImport: i0, template: "<div class=\"container\" [style.background-image]=\"imageUrl\">\n <h1>{{title}}</h1>\n <div class=\"bokeh\">\n <div *ngFor=\"let item of list\" class=\"light\"\n [style.width]=\"item.width + 'px'\"\n [style.height]=\"item.width + 'px'\"\n [style.top]=\"item.vertical + '%'\"\n [style.left]=\"item.horizontal + '%'\"\n [style.background]=\"item.color\"\n [style.filter]=\"'blur('+item.blur + 'px)'\"\n [style.animation-duration]=\"item.duration + 's'\"\n [style.animation-delay]=\"item.delay + 's'\"\n [style.animation-name]=\"'light'+item.animation\"\n ></div>\n </div>\n</div>", styles: [".container{margin:0;padding:0;width:100%;height:100%;overflow:hidden;font-family:\"Montserrat\",sans-serif;background-size:cover}.bokeh{position:relative;width:100%;height:100%;pointer-events:none;top:-50px;left:-25px}.light{position:absolute;border-radius:50%;opacity:0;animation-timing-function:linear;animation-iteration-count:infinite}@keyframes light1{25%{opacity:.75}50%{opacity:0}75%{opacity:.57}to{opacity:0}}@keyframes light2{25%{opacity:.54}50%{opacity:0}75%{opacity:.47}to{opacity:0}}@keyframes light3{25%{opacity:.39}50%{opacity:0}75%{opacity:.34}to{opacity:0}}@keyframes light4{25%{opacity:.62}50%{opacity:0}75%{opacity:.62}to{opacity:0}}@keyframes light5{25%{opacity:.26}50%{opacity:0}75%{opacity:.43}to{opacity:0}}@keyframes light6{25%{opacity:.51}50%{opacity:0}75%{opacity:.5}to{opacity:0}}@keyframes light7{25%{opacity:.44}50%{opacity:0}75%{opacity:.57}to{opacity:0}}@keyframes light8{25%{opacity:.62}50%{opacity:0}75%{opacity:.46}to{opacity:0}}@keyframes light9{25%{opacity:.69}50%{opacity:0}75%{opacity:.54}to{opacity:0}}@keyframes light10{25%{opacity:.44}50%{opacity:0}75%{opacity:.72}to{opacity:0}}h1{text-align:center;color:#fff;position:absolute;top:25%;z-index:10;opacity:.9;left:0%;right:0%}\n"], directives: [{ type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxI24ColoredLightsComponent, decorators: [{ type: Component, args: [{ selector: 'i24-colored-lights', templateUrl: './ngx-i24-colored-lights.component.html', styleUrls: ['./ngx-i24-colored-lights.component.scss'], encapsulation: ViewEncapsulation.Emulated }] }], ctorParameters: function () { return []; }, propDecorators: { colorCollection: [{ type: Input }], lightsCount: [{ type: Input }], textColor: [{ type: Input }], lightSize: [{ type: Input }], blurLevel: [{ type: Input }], title: [{ type: Input }], imageUrl: [{ type: Input }] } }); class NgxI24ColoredLightsModule { } NgxI24ColoredLightsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxI24ColoredLightsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); NgxI24ColoredLightsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxI24ColoredLightsModule, declarations: [NgxI24ColoredLightsComponent], imports: [CommonModule], exports: [NgxI24ColoredLightsComponent] }); NgxI24ColoredLightsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxI24ColoredLightsModule, imports: [[ CommonModule ]] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0, type: NgxI24ColoredLightsModule, decorators: [{ type: NgModule, args: [{ declarations: [ NgxI24ColoredLightsComponent ], imports: [ CommonModule ], exports: [ NgxI24ColoredLightsComponent ] }] }] }); /* * Public API Surface of ngx-i24-colored-lights */ /** * Generated bundle index. Do not edit. */ export { NgxI24ColoredLightsComponent, NgxI24ColoredLightsModule, NgxI24ColoredLightsService }; //# sourceMappingURL=ngx-i24-colored-lights.js.map