Run the effect to completion rather than chopping it off
This commit is contained in:
parent
b2825e8718
commit
1f95acc739
1 changed files with 2 additions and 4 deletions
|
@ -84,14 +84,14 @@ export default class Fireworks implements ICanvasEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateWorld = () => {
|
private updateWorld = () => {
|
||||||
if (!this.isRunning) return;
|
if (!this.isRunning && this.particles.length === 0) return;
|
||||||
this.update();
|
this.update();
|
||||||
this.paint();
|
this.paint();
|
||||||
this.supportsAnimationFrame.call(window, this.updateWorld);
|
this.supportsAnimationFrame.call(window, this.updateWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
private update = () => {
|
private update = () => {
|
||||||
if (this.particles.length < this.options.maxCount) {
|
if (this.particles.length < this.options.maxCount && this.isRunning) {
|
||||||
this.createFirework();
|
this.createFirework();
|
||||||
}
|
}
|
||||||
const alive = [];
|
const alive = [];
|
||||||
|
@ -142,8 +142,6 @@ export default class Fireworks implements ICanvasEffect {
|
||||||
|
|
||||||
public stop = async () => {
|
public stop = async () => {
|
||||||
this.isRunning = false;
|
this.isRunning = false;
|
||||||
this.particles = [];
|
|
||||||
this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private drawParticle = (particle: FireworksParticle): void => {
|
private drawParticle = (particle: FireworksParticle): void => {
|
||||||
|
|
Loading…
Reference in a new issue