@visactor/vrender-animate
Version:
This module provides a graph-based animation system for VRender.
59 lines (54 loc) • 1.7 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.ManualTicker = void 0;
const constant_1 = require("@visactor/vrender-core/event/constant"), default_ticker_1 = require("./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);
}
}
class ManualTicker extends default_ticker_1.DefaultTicker {
constructor(stage) {
super(stage), this.lastFrameTime = 0, this.status = constant_1.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 === constant_1.STATUS.RUNNING) return !1;
if (!this.tickerHandler) return !1;
if (!force) {
if (this.status === constant_1.STATUS.PAUSE) return !1;
if (this.ifCanStop()) return !1;
}
return this.status = constant_1.STATUS.RUNNING, !0;
}
}
exports.ManualTicker = ManualTicker;
//# sourceMappingURL=manual-ticker.js.map