mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-07-01 04:46:23 +00:00
Move scrolling logic to MessagesComponent
This commit is contained in:
@ -7,6 +7,7 @@ import { DashboardConfigService } from '../services/config.service';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { delay, retryWhen, tap } from 'rxjs/operators';
|
||||
import { FSMUpdateService } from '../services/fsmupdate.service';
|
||||
import { MessagesComponent } from '../messages/messages.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dashboard',
|
||||
@ -18,7 +19,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
polling = new BehaviorSubject<boolean>(false);
|
||||
deploymentNotificationSubscription: Subscription;
|
||||
@ViewChild('webiframe', {static: false}) webiframe: ElementRef;
|
||||
@ViewChild('tfwmessages', {static: false}) messages: ElementRef;
|
||||
@ViewChild(MessagesComponent, {static: false}) messages: MessagesComponent;
|
||||
@ViewChild('urlbar', {static: false}) urlbar: ElementRef;
|
||||
|
||||
layout = this.configService.layout;
|
||||
@ -69,7 +70,7 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
subscribeResizeOnLayoutChange() {
|
||||
this.configService.layout.subscribe(() => {
|
||||
this.emitResizeEvent();
|
||||
setTimeout(() => this.scrollMessagesToBottom(), 0);
|
||||
setTimeout(() => this.messages.scrollToBottom(), 0);
|
||||
});
|
||||
}
|
||||
|
||||
@ -132,13 +133,6 @@ export class DashboardComponent implements OnInit, OnDestroy {
|
||||
this.terminalMenuItem.next(item);
|
||||
}
|
||||
|
||||
scrollMessagesToBottom() {
|
||||
const element = this.messages.nativeElement;
|
||||
// This must be done in the Angular event loop to avoid messing up
|
||||
// change detection (not in the template like ConsoleComponent does)
|
||||
element.scrollTop = element.scrollHeight;
|
||||
}
|
||||
|
||||
iframeLoad() {
|
||||
if (this.webiframe && this.iframeUrl.value) {
|
||||
const href = this.webiframe.nativeElement.contentWindow.frames.location.href;
|
||||
|
Reference in New Issue
Block a user