message: feat(devtools): rerender tree on resize to keep tree within view
diff: -import { AfterViewInit, Component, ElementRef, Input, ViewChild } from '@angular/core';
  +import { AfterViewInit, Component, ElementRef, HostListener, Input, OnInit, ViewChild } from '@angular/core';
  import * as treemap from 'webtreemap/build/webtreemap';
  import { WebtreegraphNode } from '../../record-formatter/webtreegraph-formatter';
  +import { Subject } from 'rxjs';
  +import { throttleTime } from 'rxjs/operators';
  @Component({
  selector: 'ng-webtreegraph-visualizer',
  templateUrl: './webtreegraph-visualizer.component.html',
  styleUrls: ['./webtreegraph-visualizer.component.css'],
  })
  -export class WebtreegraphVisualizerComponent implements AfterViewInit {
  +export class WebtreegraphVisualizerComponent implements AfterViewInit, OnInit {
  @Input() set records(data: WebtreegraphNode[]) {
  // first element in data is the Application node
  this.webTreeRecords = data[0];
  @@ -16,7 +18,9 @@ export class WebtreegraphVisualizerComponent implements AfterViewInit {
  }
  }
  - webTreeRecords: any = {};
  + private changeSize = new Subject<void>();
  +
  + webTreeRecords: WebtreegraphNode;
  @ViewChild('webTree') tree: ElementRef;
  @@ -24,6 +28,13 @@ export class WebtreegraphVisualizerComponent implements AfterViewInit {
  this.updateTree();
  }
  + ngOnInit(): void {
  + this.changeSize
  + .asObservable()
  + .pipe(throttleTime(100))
  + .subscribe(_ => this.handleResize());
  + }
  +
  updateTree(): void {
  this.removeTree();
  this.createTree();
  @@ -38,4 +49,13 @@ export class WebtreegraphVisualizerComponent implements AfterViewInit {
  removeTree(): void {
  Array.from(this.tree.nativeElement.children).forEach((child: HTMLElement) => child.remove());
  }
  +
  + @HostListener('window:resize', ['$event'])
  + onResize(): void {
  + this.changeSize.next();
  + }
  +
  + handleResize(): void {
  + this.updateTree();
  + }
  }
  