Fix top scrolling

pull/16/head
Florian Hartwich 2017-10-15 12:56:16 +02:00
parent 17a4154dab
commit 371b62a0cc
3 changed files with 18 additions and 9 deletions

View File

@ -1,4 +1,4 @@
import {Component} from '@angular/core'; import {Component, HostListener} from '@angular/core';
import {NavigationEnd, NavigationStart, Router} from '@angular/router'; import {NavigationEnd, NavigationStart, Router} from '@angular/router';
import {LoginService} from './services/login-service/login-service'; import {LoginService} from './services/login-service/login-service';
import {PromotionService} from "./services/promotion-service/promotion.service"; import {PromotionService} from "./services/promotion-service/promotion.service";
@ -18,9 +18,9 @@ export class AppComponent {
loading: boolean = false; loading: boolean = false;
version = 'v' + require('./../../../package.json').version;; version = 'v' + require('./../../../package.json').version;
constructor(public loginService: LoginService, constructor(public loginService: LoginService,
private promotionService: PromotionService, private promotionService: PromotionService,
private awardingService: AwardingService, private awardingService: AwardingService,
private router: Router) { private router: Router) {
@ -30,14 +30,13 @@ constructor(public loginService: LoginService,
} }
if (event instanceof NavigationEnd) { if (event instanceof NavigationEnd) {
this.loading = false; this.loading = false;
// if (!router.url.includes('right')) { if (router.url.includes('stats') || router.url.includes('overview')) {
// window.scrollTo(0, 0); window.scrollTo({left: 0, top: 0, behavior: 'smooth'});
// } }
} }
}); });
} }
ngOnInit() { ngOnInit() {
if (this.loginService.hasPermission(2)) { if (this.loginService.hasPermission(2)) {
const fraction = this.loginService.getCurrentUser().squad.fraction; const fraction = this.loginService.getCurrentUser().squad.fraction;

View File

@ -1,4 +1,4 @@
<div class="overview fade-in" xmlns="http://www.w3.org/1999/html"> <div #overview class="overview fade-in" xmlns="http://www.w3.org/1999/html">
<div class=vertical-spacer> <div class=vertical-spacer>
</div> </div>
<div style="overflow:hidden"> <div style="overflow:hidden">

View File

@ -1,4 +1,4 @@
import {Component} from "@angular/core"; import {Component, ElementRef, ViewChild} from "@angular/core";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {WarService} from "../../services/war-service/war.service"; import {WarService} from "../../services/war-service/war.service";
import {War} from "../../models/model-interfaces"; import {War} from "../../models/model-interfaces";
@ -17,6 +17,8 @@ export class WarDetailComponent {
playerChart: any[] = []; playerChart: any[] = [];
@ViewChild('overview') private overviewContainer: ElementRef;
cellHeight = 40; cellHeight = 40;
rows = []; rows = [];
@ -52,6 +54,7 @@ export class WarDetailComponent {
"value": war.playersBlufor "value": war.playersBlufor
} }
]; ];
this.scrollOverviewTop();
}); });
} }
@ -72,4 +75,11 @@ export class WarDetailComponent {
} }
} }
scrollOverviewTop() {
try {
this.overviewContainer.nativeElement.scrollTop = 0;
} catch (err) {
}
}
} }