import {Component, OnInit} from '@angular/core';

@Component({
  selector: 'rural-attractiveness-explorer',
  templateUrl: './rural-attractiveness-explorer.component.html',
  styleUrls: ['./rural-attractiveness-explorer.component.scss'],
})
export class RuralAttractivenessExplorerComponent implements OnInit {
  menuCollapsed = true;

  constructor() {}

  listener = (e) => {
    const i = window.document.getElementById('iframe');
    if (i) {
      (<HTMLIFrameElement>i).style.height = e.data.height + 'px';
    }
  };

  ngOnInit(): void {
    window.removeEventListener('message', this.listener, false);
    window.addEventListener('message', this.listener, false);
  }

  ngOnDestroy() {
    window.removeEventListener('message', this.listener, false);
  }
}
