Skip to content

Commit 495f3f1

Browse files
committed
Scroll proof tableau to root node initially (#79)
1 parent 1605045 commit 495f3f1

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

frontend/src/app/annotate/tableau-svg/tableau-svg.component.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ChangeDetectorRef, input } from '@angular/core';
1+
import { Component, ChangeDetectorRef, ElementRef, input } from '@angular/core';
22
import { CommonModule } from "@angular/common";
33
import { Subject } from "rxjs";
44
import { Dimensions } from '@/types';
@@ -16,7 +16,10 @@ export class TableauSVG {
1616
treeDimensions$ = new Subject<Dimensions>();
1717
treeDimensions: Dimensions = {width:0, height: 0};
1818

19-
constructor(private cdref: ChangeDetectorRef) {}
19+
constructor(
20+
private cdref: ChangeDetectorRef,
21+
private element: ElementRef
22+
) {}
2023

2124
onTreeSize(size: Dimensions) {
2225
this.treeDimensions = size;
@@ -25,6 +28,10 @@ export class TableauSVG {
2528
ngAfterViewChecked() {
2629
this.treeDimensions$.next(this.treeDimensions);
2730
this.cdref.detectChanges();
31+
const width = this.treeDimensions.width;
32+
if (width) this.element.nativeElement.parentElement.scroll({
33+
left: Math.max(0, width / 2 - 500)
34+
});
2835
}
2936

3037
public readonly tree = input.required<any>();

0 commit comments

Comments
 (0)