feat: scroll to the end of the firmware log when success of faild panel visible (#1018)

This commit is contained in:
Róbert Kiss
2019-08-20 15:33:28 +02:00
committed by László Monda
parent c4269d4cf1
commit 79f467603a
3 changed files with 38 additions and 15 deletions

View File

@@ -13,10 +13,8 @@ export class XtermComponent implements OnChanges {
@ViewChild('scrollMe', { static: false }) divElement: ElementRef;
ngOnChanges(changes: SimpleChanges): void {
if (changes.logs && this.divElement && this.divElement.nativeElement) {
setTimeout(() => {
this.divElement.nativeElement.scrollTop = this.divElement.nativeElement.scrollHeight;
});
if (changes.logs) {
this.scrollToTheEnd();
}
}
@@ -24,4 +22,11 @@ export class XtermComponent implements OnChanges {
return this.logs.reduce((value, line) => value + line.message + '\n', '');
}
scrollToTheEnd(): void {
setTimeout(() => {
if (this.divElement && this.divElement.nativeElement) {
this.divElement.nativeElement.scrollTop = this.divElement.nativeElement.scrollHeight;
}
});
}
}