Mercurial > hg > ugly-duckling
view src/app/playhead/live-play-head.component.ts @ 509:041468f553e1 tip master
Merge pull request #57 from LucasThompson/fix/session-stack-max-call-stack
Fix accidental recursion in PersistentStack
author | Lucas Thompson <LucasThompson@users.noreply.github.com> |
---|---|
date | Mon, 27 Nov 2017 11:04:30 +0000 |
parents | 6015f02ef2c6 |
children |
line wrap: on
line source
/** * Created by lucast on 23/05/2017. */ import { ChangeDetectionStrategy, Component, Input, AfterViewInit, ChangeDetectorRef, OnDestroy } from '@angular/core'; import {TimePixelMapper} from './PlayHeadHelpers'; import { RenderLoopService, TaskRemover } from '../services/render-loop/render-loop.service'; @Component({ selector: 'ugly-live-play-head', template: `<ugly-play-head [currentTime]="currentTime" [timeToPixel]="timeToPixel" [colour]="colour"></ugly-play-head>`, changeDetection: ChangeDetectionStrategy.OnPush }) 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.remover = this.renderLoop.addPlayingTask((currentTime) => { this.currentTime = currentTime; this.ref.markForCheck(); }); } ngOnDestroy(): void { this.remover(); } }