Mercurial > hg > ugly-duckling
changeset 401:6015f02ef2c6
Cleanup animation tasks on destruction.
author | Lucas Thompson <dev@lucas.im> |
---|---|
date | Fri, 02 Jun 2017 19:09:31 +0100 |
parents | e06b62d949de |
children | f9d5006f76e1 |
files | src/app/playhead/live-play-head.component.ts |
diffstat | 1 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/app/playhead/live-play-head.component.ts Fri Jun 02 19:08:42 2017 +0100 +++ b/src/app/playhead/live-play-head.component.ts Fri Jun 02 19:09:31 2017 +0100 @@ -6,10 +6,13 @@ Component, Input, AfterViewInit, - ChangeDetectorRef + ChangeDetectorRef, OnDestroy } from '@angular/core'; import {TimePixelMapper} from './PlayHeadHelpers'; -import {RenderLoopService} from '../services/render-loop/render-loop.service'; +import { + RenderLoopService, + TaskRemover +} from '../services/render-loop/render-loop.service'; @Component({ selector: 'ugly-live-play-head', @@ -19,18 +22,22 @@ [colour]="colour"></ugly-play-head>`, changeDetection: ChangeDetectionStrategy.OnPush }) -export class LivePlayHeadComponent implements AfterViewInit { +export class LivePlayHeadComponent implements AfterViewInit, OnDestroy { @Input() timeToPixel: TimePixelMapper; @Input() colour: string; private currentTime = 0; + private remover: TaskRemover; constructor(private renderLoop: RenderLoopService, private ref: ChangeDetectorRef) {} ngAfterViewInit(): void { - this.renderLoop.addPlayingTask((currentTime) => { + this.remover = this.renderLoop.addPlayingTask((currentTime) => { this.currentTime = currentTime; this.ref.markForCheck(); }); } + ngOnDestroy(): void { + this.remover(); + } }