MCPcopy
hub / github.com/palantir/blueprint / Timeline

Class Timeline

packages/landing-app/src/logo.ts:584–628  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

582}
583
584export class Timeline implements ITickable {
585 private queue: IKeyFrame[] = [];
586
587 public reset() {
588 this.queue.length = 0;
589 return this;
590 }
591
592 public after(duration: number, callback?: IRenderCallback) {
593 this.tween(duration).tween(0, callback);
594 return this;
595 }
596
597 public tween(duration: number, callback?: IAnimatedCallback) {
598 this.queue.push({ duration, callback });
599 return this;
600 }
601
602 public tick(elapsed: number) {
603 if (this.queue.length === 0) {
604 return false;
605 }
606
607 const anim = this.queue[0];
608 const { duration, callback } = anim;
609 let { startTime } = anim;
610
611 if (startTime == null) {
612 anim.startTime = startTime = elapsed;
613 }
614
615 if (elapsed - startTime >= duration) {
616 if (callback != null) {
617 callback(1.0);
618 }
619 this.queue.shift();
620 return this.queue.length > 0;
621 } else {
622 if (callback != null) {
623 callback((elapsed - startTime) / duration);
624 }
625 return true;
626 }
627 }
628}
629
630export class Ticker implements ITickable {
631 public constructor(private callback: IRenderCallback) {}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected