Make sure the splash screen element exists before adding an event to it

This commit is contained in:
Sercan Yemen 2018-02-05 11:29:30 +03:00
parent b0101a1f8c
commit f246fab1f4

View File

@ -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()
{