UNPKG

tsparticles

Version:

Porting of the abandoned Vincent Garreau's particles.js, converted in TypeScript. Added many new cool features and various bug fixes.

24 lines (23 loc) 749 B
export class FrameManager { constructor(container) { this.container = container; } nextFrame(timestamp) { const container = this.container; const options = container.options; const fpsLimit = options.fpsLimit > 0 ? options.fpsLimit : 60; if (container.lastFrameTime !== undefined && timestamp < container.lastFrameTime + (1000 / fpsLimit)) { container.play(); return; } const delta = timestamp - container.lastFrameTime; container.lastFrameTime = timestamp; container.particles.draw(delta); if (!options.particles.move.enable) { container.pause(); } else { container.play(); } } }