Browse Source

fix(theme-shared): fix loader bar problem

pull/3919/head
mehmet-erim 6 years ago
parent
commit
a5ee78910a
  1. 5
      npm/ng-packs/packages/theme-shared/src/lib/components/loader-bar/loader-bar.component.scss
  2. 13
      npm/ng-packs/packages/theme-shared/src/lib/components/loader-bar/loader-bar.component.ts

5
npm/ng-packs/packages/theme-shared/src/lib/components/loader-bar/loader-bar.component.scss

@ -16,6 +16,9 @@
left: 0; left: 0;
position: fixed; position: fixed;
top: 0; top: 0;
transition: width 0.4s ease;
&.progressing {
transition: width 0.4s ease;
}
} }
} }

13
npm/ng-packs/packages/theme-shared/src/lib/components/loader-bar/loader-bar.component.ts

@ -12,6 +12,7 @@ import { filter } from 'rxjs/operators';
<div id="abp-loader-bar" [ngClass]="containerClass" [class.is-loading]="isLoading"> <div id="abp-loader-bar" [ngClass]="containerClass" [class.is-loading]="isLoading">
<div <div
class="abp-progress" class="abp-progress"
[class.progressing]="progressLevel"
[style.width.vw]="progressLevel" [style.width.vw]="progressLevel"
[ngStyle]="{ [ngStyle]="{
'background-color': color, 'background-color': color,
@ -40,7 +41,7 @@ export class LoaderBarComponent implements OnDestroy, OnInit {
intervalPeriod = 350; intervalPeriod = 350;
stopDelay = 820; stopDelay = 800;
@Input() @Input()
filter = (action: StartLoader | StopLoader) => filter = (action: StartLoader | StopLoader) =>
@ -85,10 +86,11 @@ export class LoaderBarComponent implements OnDestroy, OnInit {
} }
startLoading() { startLoading() {
if (this.isLoading || this.progressLevel !== 0) return; if (this.isLoading || (this.interval && !this.interval.closed)) return;
this.isLoading = true; this.isLoading = true;
this.interval = interval(this.intervalPeriod).subscribe(() => {
const progress = () => {
if (this.progressLevel < 75) { if (this.progressLevel < 75) {
this.progressLevel += Math.random() * 10; this.progressLevel += Math.random() * 10;
} else if (this.progressLevel < 90) { } else if (this.progressLevel < 90) {
@ -99,7 +101,10 @@ export class LoaderBarComponent implements OnDestroy, OnInit {
this.interval.unsubscribe(); this.interval.unsubscribe();
} }
this.cdRef.detectChanges(); this.cdRef.detectChanges();
}); };
progress();
this.interval = interval(this.intervalPeriod).subscribe(() => progress());
} }
stopLoading() { stopLoading() {

Loading…
Cancel
Save