mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-10 12:35:07 +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,18 +15,27 @@ export class FuseSplashScreenService
|
||||||
private router: Router
|
private router: Router
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
// Get the splash screen element
|
||||||
this.splashScreenEl = this.document.body.querySelector('#fuse-splash-screen');
|
this.splashScreenEl = this.document.body.querySelector('#fuse-splash-screen');
|
||||||
|
|
||||||
const hideOnLoad = this.router.events.subscribe((event) => {
|
// If the splash screen element exists...
|
||||||
if ( event instanceof NavigationEnd )
|
if ( this.splashScreenEl )
|
||||||
{
|
{
|
||||||
setTimeout(() => {
|
// Hide it on the first NavigationEnd event
|
||||||
this.hide();
|
const hideOnLoad = this.router.events.subscribe((event) => {
|
||||||
hideOnLoad.unsubscribe();
|
if ( event instanceof NavigationEnd )
|
||||||
}, 0);
|
{
|
||||||
|
setTimeout(() => {
|
||||||
|
this.hide();
|
||||||
|
|
||||||
|
// Unsubscribe from this event so it
|
||||||
|
// won't get triggered again
|
||||||
|
hideOnLoad.unsubscribe();
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
show()
|
show()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user