| 123456789101112131415161718192021222324252627 |
- import * as d3 from 'd3'
- export class Player {
- private oneStep: () => void
- private timerIndex = 0
- constructor(oneStep: () => void) {
- this.oneStep = oneStep
- }
- pause() {
- this.timerIndex++
- }
- play() {
- this.start(this.timerIndex)
- }
- private start(localTimeIndex: number) {
- const timer = d3.timer(() => {
- if (localTimeIndex < this.timerIndex) {
- timer.stop()
- }
- this.oneStep()
- })
- }
- }
|