From ce638e717d9d5c4eee0ad819a158e31c945f69f1 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Fri, 18 Dec 2020 18:41:01 -0700 Subject: [PATCH] Run the effect to completion rather than chopping it off --- src/effects/fireworks/index.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/effects/fireworks/index.ts b/src/effects/fireworks/index.ts index 4ca5c59fa7..96a27531af 100644 --- a/src/effects/fireworks/index.ts +++ b/src/effects/fireworks/index.ts @@ -84,14 +84,14 @@ export default class Fireworks implements ICanvasEffect { } private updateWorld = () => { - if (!this.isRunning) return; + if (!this.isRunning && this.particles.length === 0) return; this.update(); this.paint(); this.supportsAnimationFrame.call(window, this.updateWorld); } private update = () => { - if (this.particles.length < this.options.maxCount) { + if (this.particles.length < this.options.maxCount && this.isRunning) { this.createFirework(); } const alive = []; @@ -142,8 +142,6 @@ export default class Fireworks implements ICanvasEffect { public stop = async () => { this.isRunning = false; - this.particles = []; - this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height); } private drawParticle = (particle: FireworksParticle): void => {