MCPcopy Index your code
hub / github.com/JavaCS3/xterm-player / AnimationFrameTicker

Class AnimationFrameTicker

src/Timer.ts:59–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59export class AnimationFrameTicker implements ITicker {
60 private _rafid: number = 0
61 private _cb: TickerCallback | null = null
62
63 public get running(): boolean { return this._rafid != 0 }
64
65 private _tick() {
66 if (this._cb) { this._cb() }
67 if (this._rafid) {
68 this._rafid = requestAnimationFrame(this._tick.bind(this))
69 }
70 }
71 public start(cb: TickerCallback): void {
72 this.stop()
73 this._cb = cb
74 this._rafid = requestAnimationFrame(this._tick.bind(this))
75 }
76 public stop(): void {
77 if (this._rafid) {
78 cancelAnimationFrame(this._rafid)
79 this._rafid = 0
80 }
81 this._cb = null
82 }
83 public now(): number { return performance.now() }
84}
85
86const TIMESCALE_MIN = 0, TIMESCALE_MAX = 5
87

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected