Add CPU eating loader waiting for configuration to finish

This commit is contained in:
Kristóf Tóth 2019-08-28 10:17:43 +02:00
parent 4ac350d665
commit 65c7c727f5
3 changed files with 98 additions and 0 deletions

View File

@ -0,0 +1,7 @@
<div *ngIf="loading" class="loading-container">
<div class=" loader">
<div class="outer"></div>
<div class="middle"></div>
<div class="inner"></div>
</div>
</div>

View File

@ -0,0 +1,62 @@
.loading-container {
position: absolute;
top: 0;
left: 0;
margin: 0;
padding: 0;
display: flex;
width: 100%;
height: 100%;
align-items: center;
justify-content: center;
background: rgba(0, 0, 0, 0.2);
z-index: 99999;
filter: blur(0px)!important;
}
.loader {
position: relative;
filter: blur(0px) !important;
}
.outer,
.middle,
.inner {
border: 3px solid transparent;
border-top-color: #277EEC;
border-right-color: #277EEC;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
}
.outer {
width: 3.5em;
height: 3.5em;
margin-left: -1.75em;
margin-top: -1.75em;
animation: spin 2s linear infinite;
}
.middle {
width: 2.1em;
height: 2.1em;
margin-left: -1.05em;
margin-top: -1.05em;
animation: spin 1.75s linear reverse infinite;
}
.inner {
width: 0.8em;
height: 0.8em;
margin-left: -0.4em;
margin-top: -0.4em;
animation: spin 1.5s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}

View File

@ -0,0 +1,29 @@
import { Component, Input, AfterViewInit, OnInit } from '@angular/core';
import { ConfigReadyService } from '../services/config.service';
@Component({
selector: 'app-loader',
templateUrl: './loader.component.html',
styleUrls: ['./loader.component.scss']
})
export class LoaderComponent implements OnInit, AfterViewInit {
@Input() toBlur: HTMLElement;
loading = true;
constructor(private configReadyService: ConfigReadyService) {}
ngOnInit() {
this.configReadyService.init();
}
ngAfterViewInit() {
this.toBlur.classList.add('blur');
this.configReadyService.configDone.subscribe(
() => {
this.loading = false;
this.toBlur.classList.remove('blur');
}
);
}
}