UNPKG

@visactor/vrender-animate

Version:

This module provides a graph-based animation system for VRender.

53 lines (50 loc) 1.47 kB
import { STATUS } from "@visactor/vrender-core"; import { DefaultTicker } from "./default-ticker"; class ManualTickHandler { constructor() { this.released = !1, this.currentTime = -1; } tick(interval, cb) { this.currentTime < 0 && (this.currentTime = 0), this.currentTime += interval, cb(this); } release() { this.released = !0; } getTime() { return this.currentTime; } tickTo(time, cb) { this.currentTime < 0 && (this.currentTime = 0); const interval = time - this.currentTime; this.tick(interval, cb); } } export class ManualTicker extends DefaultTicker { constructor(stage) { super(stage), this.lastFrameTime = 0, this.status = STATUS.RUNNING; } setupTickHandler() { const handler = new ManualTickHandler; return this.tickerHandler && this.tickerHandler.release(), this.tickerHandler = handler, !0; } checkSkip(delta) { return !1; } getTime() { return this.tickerHandler.getTime(); } tickAt(time) { this.tickTo(time); } start(force = !1) { if (this.status === STATUS.RUNNING) return !1; if (!this.tickerHandler) return !1; if (!force) { if (this.status === STATUS.PAUSE) return !1; if (this.ifCanStop()) return !1; } return this.status = STATUS.RUNNING, !0; } } //# sourceMappingURL=manual-ticker.js.map