# HG changeset patch # User Lucas Thompson # Date 1496427158 -3600 # Node ID 40ea40ebc2b3ff86bfcb14ee8f75b5081f1d2d2c # Parent f9d5006f76e1b2a034f0bd6616353d0563954e24 Have animation controlled by a prop, clearing up animation tasks when set to false. Wire up accordingly. diff -r f9d5006f76e1 -r 40ea40ebc2b3 src/app/analysis-item/analysis-item.component.html --- a/src/app/analysis-item/analysis-item.component.html Fri Jun 02 19:10:47 2017 +0100 +++ b/src/app/analysis-item/analysis-item.component.html Fri Jun 02 19:12:38 2017 +0100 @@ -32,18 +32,23 @@
- + [isAnimated]="isActive" + > + + ; @Input() unit: string; + @Input() set isAnimated(isAnimated: boolean) { + this.mIsAnimated = isAnimated; + if (this.removers.length) { + this.removers.forEach(remove => remove()); + this.removers = []; + } + if (isAnimated) { + this.addTasks(); + } + } + + private removers: TaskRemover[]; + private mIsAnimated: boolean; constructor(private renderLoop: RenderLoopService) { super(); + this.removers = []; } ngAfterViewInit(): void { super.ngAfterViewInit(); this.inspectorRenderers.forEach(renderer => { - this.renderLoop.addPlayingTask(renderer.updatePosition); - renderer.renderInspector(this.cachedRanged, this.unit); + renderer.renderInspector(this.cachedRange, this.unit); }); + this.addTasks(); + } + + private addTasks(): void { + if (this.inspectorRenderers && this.mIsAnimated) { + this.inspectorRenderers.forEach(renderer => { + this.removers.push( + this.renderLoop.addPlayingTask(renderer.updatePosition) + ); + }); + } } } diff -r f9d5006f76e1 -r 40ea40ebc2b3 src/app/visualisations/vertical-scale.component.ts --- a/src/app/visualisations/vertical-scale.component.ts Fri Jun 02 19:10:47 2017 +0100 +++ b/src/app/visualisations/vertical-scale.component.ts Fri Jun 02 19:12:38 2017 +0100 @@ -20,13 +20,13 @@ @ContentChildren( VerticalScaleRenderer ) bounded: QueryList; - protected cachedRanged: [number, number]; + protected cachedRange: [number, number]; ngAfterViewInit(): void { this.bounded.forEach(component => { - this.cachedRanged = component.range; - if (this.cachedRanged) { - component.renderScale(this.cachedRanged); + this.cachedRange = component.range; + if (this.cachedRange) { + component.renderScale(this.cachedRange); } }); }