mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-10 04:25:08 +00:00
Make sure the splash screen element exists before adding an event to it
This commit is contained in:
parent
b0101a1f8c
commit
f246fab1f4
|
@ -15,19 +15,28 @@ export class FuseSplashScreenService
|
|||
private router: Router
|
||||
)
|
||||
{
|
||||
// Get the splash screen element
|
||||
this.splashScreenEl = this.document.body.querySelector('#fuse-splash-screen');
|
||||
|
||||
// If the splash screen element exists...
|
||||
if ( this.splashScreenEl )
|
||||
{
|
||||
// Hide it on the first NavigationEnd event
|
||||
const hideOnLoad = this.router.events.subscribe((event) => {
|
||||
if ( event instanceof NavigationEnd )
|
||||
{
|
||||
setTimeout(() => {
|
||||
this.hide();
|
||||
|
||||
// Unsubscribe from this event so it
|
||||
// won't get triggered again
|
||||
hideOnLoad.unsubscribe();
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
show()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user