UNPKG

@lightningjs/renderer

Version:
89 lines 2.53 kB
export var StopMethodFlags; (function (StopMethodFlags) { StopMethodFlags[StopMethodFlags["Immediate"] = 0] = "Immediate"; StopMethodFlags[StopMethodFlags["Reset"] = 1] = "Reset"; StopMethodFlags[StopMethodFlags["Reverse"] = 2] = "Reverse"; })(StopMethodFlags || (StopMethodFlags = {})); export const getStopMethodFlag = (method) => { if (method === undefined || method === 'immediate') { return StopMethodFlags.Immediate; } switch (method) { case 'reverse': return StopMethodFlags.Reverse; case 'reset': return StopMethodFlags.Reset; } return StopMethodFlags.Immediate; }; export var TickerState; (function (TickerState) { TickerState[TickerState["Pending"] = 0] = "Pending"; TickerState[TickerState["Playing"] = 1] = "Playing"; TickerState[TickerState["Stopping"] = 2] = "Stopping"; TickerState[TickerState["Paused"] = 3] = "Paused"; TickerState[TickerState["Destroyed"] = 4] = "Destroyed"; TickerState[TickerState["Stopped"] = 5] = "Stopped"; TickerState[TickerState["Finished"] = 6] = "Finished"; })(TickerState || (TickerState = {})); export const TickerSettingsKeys = { delay: true, duration: true, loop: true, repeat: true, reverse: true, stopMethod: true, autoPlay: true, }; //freeze the keys object to prevent modification Object.freeze(TickerSettingsKeys); /** * Returns a new unique ID */ let tickerId = 1; export function generateTickerId() { return tickerId++; } const TickerTemplate = { id: 0, state: TickerState.Pending, delay: 0, duration: 0, easing: 'linear', loop: false, repeat: 0, reverse: false, stopMethod: StopMethodFlags.Immediate, autoPlay: true, }; export class TickerClass { id = generateTickerId(); //settings delay; duration; loop; repeat; reverse; stopMethod; pausedAt = 0; startTime = 0; endTime = 0; progressTime = 0; constructor(settings) { this.delay = settings.delay; this.duration = settings.duration; this.loop = settings.loop; this.repeat = settings.repeat; this.reverse = settings.reverse; this.stopMethod = getStopMethodFlag(settings.stopMethod); } firstTick(time) { this.startTime = time; this.endTime = time + this.duration; } tick(time) { const p = this.progressTime = time - this.startTime; const s = this.startTime; } } //# sourceMappingURL=Ticker.js.map