changeset 388:5f775358c3cf

Introduce vertical-scale component which is a polymorphic container, the child components know how to render their own scales.
author Lucas Thompson <dev@lucas.im>
date Thu, 01 Jun 2017 10:02:37 +0100
parents 2ec1e795f46c
children 29b817e49a22
files src/app/app.module.ts src/app/visualisations/vertical-scale.component.ts
diffstat 2 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/app/app.module.ts	Wed May 31 19:31:56 2017 +0100
+++ b/src/app/app.module.ts	Thu Jun 01 10:02:37 2017 +0100
@@ -36,6 +36,7 @@
 import {NotesComponent} from './visualisations/notes/notes.component';
 import {InstantsComponent} from './visualisations/instants/instants.component';
 import {GridComponent} from './visualisations/grid/grid.component';
+import {VerticalScaleComponent} from "./visualisations/vertical-scale.component";
 
 export function createAudioContext(): AudioContext {
   return new (
@@ -128,7 +129,8 @@
     TracksComponent,
     NotesComponent,
     InstantsComponent,
-    GridComponent
+    GridComponent,
+    VerticalScaleComponent
   ],
   imports: [
     BrowserModule,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/app/visualisations/vertical-scale.component.ts	Thu Jun 01 10:02:37 2017 +0100
@@ -0,0 +1,30 @@
+/**
+ * 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);
+      }
+    });
+  }
+}