Mercurial > hg > ugly-duckling
view src/app/visualisations/instants/instants.component.ts @ 383:1241ca979fd9
Refactor based on pattern which emerged when implementing multiple components. Still some very obvious dupe regarding the ElementRef stuff, I don't think ViewChild decorated props are inherited.. but I haven't actually verified that.
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Wed, 31 May 2017 19:14:46 +0100 |
parents | b220ed78a250 |
children | 7119d62121f0 |
line wrap: on
line source
/** * Created by lucast on 31/05/2017. */ import {WavesComponent} from '../waves-base.component'; import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, Input, ViewChild } from '@angular/core'; import {Instant} from '../FeatureUtilities'; import Waves from 'waves-ui-piper'; @Component({ selector: 'ugly-instants', templateUrl: '../waves-template.html', styleUrls: ['../waves-template.css'], changeDetection: ChangeDetectionStrategy.OnPush }) export class InstantsComponent extends WavesComponent<Instant[]> { @ViewChild('track') trackDiv: ElementRef; @Input() set instants(instants: Instant[]) { this.feature = instants; } protected get containerHeight(): number { return this.trackDiv.nativeElement.getBoundingClientRect().height; } protected get trackContainer(): ElementRef { return this.trackDiv; } protected get featureLayers(): Layer[] { return [ new Waves.helpers.TickLayer( this.feature, { height: this.height, color: this.colour, labelPosition: 'bottom', shadeSegments: true } ) ]; } }