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 {LoginService} from './services/login-service/login-service';
import {PromotionService} from "./services/promotion-service/promotion.service";
@ -18,9 +18,9 @@ export class AppComponent {
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 awardingService: AwardingService,
private router: Router) {
@ -30,14 +30,13 @@ constructor(public loginService: LoginService,
}
if (event instanceof NavigationEnd) {
this.loading = false;
// if (!router.url.includes('right')) {
// window.scrollTo(0, 0);
// }
if (router.url.includes('stats') || router.url.includes('overview')) {
window.scrollTo({left: 0, top: 0, behavior: 'smooth'});
}
}
});
}
ngOnInit() {
if (this.loginService.hasPermission(2)) {
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>
<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 {WarService} from "../../services/war-service/war.service";
import {War} from "../../models/model-interfaces";
@ -17,6 +17,8 @@ export class WarDetailComponent {
playerChart: any[] = [];
@ViewChild('overview') private overviewContainer: ElementRef;
cellHeight = 40;
rows = [];
@ -52,6 +54,7 @@ export class WarDetailComponent {
"value": war.playersBlufor
}
];
this.scrollOverviewTop();
});
}
@ -72,4 +75,11 @@ export class WarDetailComponent {
}
}
scrollOverviewTop() {
try {
this.overviewContainer.nativeElement.scrollTop = 0;
} catch (err) {
}
}
}