mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-01-10 12:35:07 +00:00
Move the layout settings reset to the 'NavigationEnd' to make things smoother on lazily loaded components
This commit is contained in:
parent
5c66d95951
commit
ed4a3cb8d7
|
@ -1,5 +1,5 @@
|
||||||
import { Inject, Injectable, InjectionToken, Optional } from '@angular/core';
|
import { Inject, Injectable, InjectionToken, Optional } from '@angular/core';
|
||||||
import { NavigationStart, Router } from '@angular/router';
|
import { NavigationEnd, NavigationStart, Router } from '@angular/router';
|
||||||
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||||
import { Platform } from '@angular/cdk/platform';
|
import { Platform } from '@angular/cdk/platform';
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ export class FuseConfigService
|
||||||
{
|
{
|
||||||
config: any;
|
config: any;
|
||||||
defaultConfig: any;
|
defaultConfig: any;
|
||||||
|
isSetConfigRan = false;
|
||||||
|
|
||||||
onConfigChanged: BehaviorSubject<any>;
|
onConfigChanged: BehaviorSubject<any>;
|
||||||
|
|
||||||
|
@ -70,8 +71,19 @@ export class FuseConfigService
|
||||||
// layout on every navigation start
|
// layout on every navigation start
|
||||||
router.events.subscribe(
|
router.events.subscribe(
|
||||||
(event) => {
|
(event) => {
|
||||||
|
|
||||||
if ( event instanceof NavigationStart )
|
if ( event instanceof NavigationStart )
|
||||||
{
|
{
|
||||||
|
this.isSetConfigRan = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( event instanceof NavigationEnd )
|
||||||
|
{
|
||||||
|
if ( this.isSetConfigRan )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.setConfig({
|
this.setConfig({
|
||||||
layout: this.defaultConfig.layout
|
layout: this.defaultConfig.layout
|
||||||
}
|
}
|
||||||
|
@ -91,6 +103,9 @@ export class FuseConfigService
|
||||||
*/
|
*/
|
||||||
setConfig(config): void
|
setConfig(config): void
|
||||||
{
|
{
|
||||||
|
// Set the SetConfigRan true
|
||||||
|
this.isSetConfigRan = true;
|
||||||
|
|
||||||
// Set the config from the given object
|
// Set the config from the given object
|
||||||
// Ugly, but works for now...
|
// Ugly, but works for now...
|
||||||
this.config = {
|
this.config = {
|
||||||
|
@ -98,7 +113,7 @@ export class FuseConfigService
|
||||||
...config,
|
...config,
|
||||||
layout : {
|
layout : {
|
||||||
...this.config.layout,
|
...this.config.layout,
|
||||||
...config.layout,
|
...config.layout
|
||||||
},
|
},
|
||||||
colorClasses: {
|
colorClasses: {
|
||||||
...this.config.colorClasses,
|
...this.config.colorClasses,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user