Skip to content
Permalink
Browse files

Fixes loader for angular event handling

  • Loading branch information...
nezhar committed Apr 14, 2019
1 parent c59e1e6 commit 7e17a8dad216e556c084593a569f9debb1b66a61
@@ -1,4 +1,4 @@
<div class="loading-screen-wrapper" *ngIf="loading">
<div class="loading-screen-wrapper">
<div class="loading-screen-icon">
<div class="blobs">
<div class="blob-center"></div>
@@ -1,4 +1,4 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, OnDestroy } from '@angular/core';
import { LoadingScreenService } from "../../services/loading-screen/loading-screen.service";
import { Subscription } from "rxjs";
import { debounceTime } from "rxjs/operators";
@@ -8,20 +8,25 @@ import { debounceTime } from "rxjs/operators";
templateUrl: './loading-screen.component.html',
styleUrls: ['./loading-screen.component.scss']
})
export class LoadingScreenComponent implements OnInit, OnDestroy {
export class LoadingScreenComponent implements AfterViewInit, OnDestroy {

debounceTime: number = 200;
loading: boolean = false;
loadingSubscription: Subscription;

constructor(private loadingScreenService: LoadingScreenService) {
constructor(private loadingScreenService: LoadingScreenService,
private _elmRef: ElementRef,
private _changeDetectorRef: ChangeDetectorRef) {
}

ngOnInit() {
this.loadingSubscription = this.loadingScreenService.loadingStatus.pipe(
debounceTime(200)
).subscribe((value) => {
this.loading = value;
});
ngAfterViewInit(): void {
this._elmRef.nativeElement.style.display = 'none';
this.loadingSubscription = this.loadingScreenService.loadingStatus.pipe(debounceTime(this.debounceTime)).subscribe(
(status: boolean) => {
this._elmRef.nativeElement.style.display = status ? 'block' : 'none';
this._changeDetectorRef.detectChanges();
}
);
}

ngOnDestroy() {

0 comments on commit 7e17a8d

Please sign in to comment.
You can’t perform that action at this time.