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