From b52c5fc484011d9a89e209bd0b77e2f7274b4a77 Mon Sep 17 00:00:00 2001 From: HardiReady Date: Mon, 26 Feb 2018 08:53:51 +0100 Subject: [PATCH] auto scroll top on stats table change --- .../war-detail/scoreboard/scoreboard.component.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.ts b/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.ts index ae07c5b..5c71985 100644 --- a/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.ts +++ b/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.ts @@ -1,4 +1,4 @@ -import {Component, EventEmitter, SimpleChanges} from "@angular/core"; +import {Component, ElementRef, EventEmitter, SimpleChanges} from "@angular/core"; import {War} from "../../../models/model-interfaces"; import {Fraction} from "../../../utils/fraction.enum"; @@ -30,10 +30,7 @@ export class ScoreboardComponent { sortDescending: 'glyphicon glyphicon-triangle-bottom', }; - constructor() { - } - - ngOnInit() { + constructor(private elRef: ElementRef) { } selectPlayerDetail(view: number, playerName: string) { @@ -41,6 +38,8 @@ export class ScoreboardComponent { } ngOnChanges(changes: SimpleChanges) { + this.elRef.nativeElement.querySelector('.datatable-body').scrollTo(0, 0); + if (changes.war) { this.rows = changes.war.currentValue.players; }