view src/app/visualisations/vertical-scale.component.ts @ 389:29b817e49a22

Introduce interface VerticallyBounded, which describes a component with a vertical range and the ability to render a scale on itself. VerticallyBoundedWavesComponent partially implements this interface, in that it adds a ScaleLayer to itself - derived instances provide the means of obtaining the scale.
author Lucas Thompson <dev@lucas.im>
date Thu, 01 Jun 2017 10:04:41 +0100
parents 5f775358c3cf
children a02e6ec4a9d2
line wrap: on
line source
/**
 * Created by lucas on 01/06/2017.
 */
import {VerticallyBounded} from "./waves-base.component";
import {
  ChangeDetectionStrategy,
  Component,
  ContentChildren,
  QueryList,
  AfterViewInit
} from "@angular/core";

@Component({
  selector: 'ugly-vertical-scale',
  template: '<ng-content></ng-content>',
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class VerticalScaleComponent implements AfterViewInit {

  @ContentChildren(VerticallyBounded) bounded: QueryList<VerticallyBounded>;

  ngAfterViewInit(): void {
    this.bounded.forEach(component => {
      const range = component.range;
      if (range) {
        component.renderScale(range);
      }
    });
  }
}