suppress bg reloading on page change
parent
cdb63ba41b
commit
5943a40576
|
@ -30,7 +30,7 @@ export class AppComponent {
|
|||
}
|
||||
if (event instanceof NavigationEnd) {
|
||||
this.loading = false;
|
||||
if (router.url.includes('overview')) {
|
||||
if (router.url.includes(RouteConfig.overviewPath)) {
|
||||
window.scrollTo({left: 0, top: 0, behavior: 'smooth'});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import {RouteConfig} from "../app.config";
|
|||
import {AwardingService} from "../services/army-management/awarding.service";
|
||||
import {Fraction} from "../utils/fraction.enum";
|
||||
import {DOCUMENT} from "@angular/common";
|
||||
import {CSSHelpers} from "../global.helpers";
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -37,12 +38,7 @@ export class ArmyMemberComponent {
|
|||
|
||||
ngOnInit() {
|
||||
// set background image css
|
||||
const backgroundCss = ' background-image: url(../assets/bg.jpg);\n' +
|
||||
' background-size: cover;\n' +
|
||||
' background-attachment: fixed;\n' +
|
||||
' background-position: center;\n' +
|
||||
' background-repeat: no-repeat;';
|
||||
this.document.getElementById('right').setAttribute('style', backgroundCss);
|
||||
this.document.getElementById('right').setAttribute('style', CSSHelpers.getBackgroundCSS('../assets/bg.jpg'));
|
||||
|
||||
this.subscription = this.route.params
|
||||
.map(params => params['id'])
|
||||
|
@ -59,7 +55,9 @@ export class ArmyMemberComponent {
|
|||
};
|
||||
|
||||
ngOnDestroy() {
|
||||
this.document.getElementById('right').setAttribute('style', '');
|
||||
if (this.router.url !== '/' + RouteConfig.overviewPath) {
|
||||
this.document.getElementById('right').setAttribute('style', '');
|
||||
}
|
||||
}
|
||||
|
||||
backToOverview() {
|
||||
|
|
|
@ -4,6 +4,8 @@ import {ArmyService} from "../services/army-service/army.service";
|
|||
import {ActivatedRoute, Router} from "@angular/router";
|
||||
import {Fraction} from "../utils/fraction.enum";
|
||||
import {DOCUMENT} from "@angular/common";
|
||||
import {RouteConfig} from "../app.config";
|
||||
import {CSSHelpers} from "../global.helpers";
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -25,12 +27,7 @@ export class ArmyComponent {
|
|||
|
||||
ngOnInit() {
|
||||
// set background image css
|
||||
const backgroundCss = ' background-image: url(../assets/bg.jpg);\n' +
|
||||
' background-size: cover;\n' +
|
||||
' background-attachment: fixed;\n' +
|
||||
' background-position: center;\n' +
|
||||
' background-repeat: no-repeat;';
|
||||
this.document.getElementById('right').setAttribute('style', backgroundCss);
|
||||
this.document.getElementById('right').setAttribute('style', CSSHelpers.getBackgroundCSS('../assets/bg.jpg'));
|
||||
|
||||
// init army data
|
||||
this.armyService.getArmy()
|
||||
|
@ -40,7 +37,9 @@ export class ArmyComponent {
|
|||
};
|
||||
|
||||
ngOnDestroy() {
|
||||
this.document.getElementById('right').setAttribute('style', '');
|
||||
if (this.router.url.includes(RouteConfig.overviewPath)) {
|
||||
this.document.getElementById('right').setAttribute('style', '');
|
||||
}
|
||||
}
|
||||
|
||||
select(memberId) {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
export const CSSHelpers = {
|
||||
getBackgroundCSS: (imageUrl) => {
|
||||
return 'background-image: url(' + imageUrl + ');' +
|
||||
'background-size: cover;' +
|
||||
'background-attachment: fixed;' +
|
||||
'background-position: center;' +
|
||||
'background-repeat: no-repeat;';
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue