@@ -21,9 +21,9 @@ import { CoreUtilsProvider } from '@providers/utils/utils';
2121/**
2222 * Component to show a loading spinner and message while data is being loaded.
2323 *
24- * It will show a spinner with a message and hide all the content until 'dataLoaded ' variable is set to true .
25- * If 'message' and 'dynMessage' attributes aren 't set, default message "Loading" is shown.
26- * 'message' attribute accepts hardcoded strings, variables, filters, etc. E.g. message="'core.loading' | translate".
24+ * It will show a spinner with a message and hide all the content until 'hideUntil ' variable is set to a truthy value (!!hideUntil) .
25+ * If 'message' isn 't set, default message "Loading" is shown.
26+ * 'message' attribute accepts hardcoded strings, variables, filters, etc. E.g. [ message] ="'core.loading' | translate".
2727 *
2828 * Usage:
2929 * <core-loading [message]="loadingMessage" [hideUntil]="dataLoaded">
@@ -44,7 +44,7 @@ import { CoreUtilsProvider } from '@providers/utils/utils';
4444 animations : [ coreShowHideAnimation ]
4545} )
4646export class CoreLoadingComponent implements OnInit , OnChanges {
47- @Input ( ) hideUntil : boolean ; // Determine when should the contents be shown.
47+ @Input ( ) hideUntil : any ; // Determine when should the contents be shown.
4848 @Input ( ) message ?: string ; // Message to show while loading.
4949 @ViewChild ( 'content' ) content : ElementRef ;
5050
@@ -69,15 +69,15 @@ export class CoreLoadingComponent implements OnInit, OnChanges {
6969 }
7070
7171 // Add class if loaded on init.
72- if ( this . hideUntil ) {
72+ if ( ! ! this . hideUntil ) {
7373 this . element . classList . add ( 'core-loading-loaded' ) ;
7474 this . content . nativeElement . classList . add ( 'core-loading-content' ) ;
7575 }
7676 }
7777
7878 ngOnChanges ( changes : { [ name : string ] : SimpleChange } ) : void {
7979 if ( changes . hideUntil ) {
80- if ( changes . hideUntil . currentValue === true ) {
80+ if ( ! ! this . hideUntil ) {
8181 setTimeout ( ( ) => {
8282 // Content is loaded so, center the spinner on the content itself.
8383 this . element . classList . add ( 'core-loading-loaded' ) ;
@@ -96,7 +96,7 @@ export class CoreLoadingComponent implements OnInit, OnChanges {
9696 // Trigger the event after a timeout since the elements inside ngIf haven't been added to DOM yet.
9797 setTimeout ( ( ) => {
9898 this . eventsProvider . trigger ( CoreEventsProvider . CORE_LOADING_CHANGED , {
99- loaded : changes . hideUntil . currentValue ,
99+ loaded : ! ! this . hideUntil ,
100100 uniqueId : this . uniqueId
101101 } ) ;
102102 } ) ;
0 commit comments