Skip to content

Commit

Permalink
feat: added more events to emitters and polygon mask
Browse files Browse the repository at this point in the history
  • Loading branch information
matteobruni committed Nov 6, 2021
1 parent 13fe1fe commit cea5ed6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
14 changes: 14 additions & 0 deletions plugins/emitters/src/EmitterInstance.ts
Expand Up @@ -96,6 +96,13 @@ export class EmitterInstance {
this.lifeCount = this.emitterOptions.life.count ?? -1;
this.immortal = this.lifeCount <= 0;

tsParticles.dispatchEvent("emitterCreated", {
container,
data: {
emitter: this
}
});

this.play();
}

Expand Down Expand Up @@ -242,6 +249,13 @@ export class EmitterInstance {

private destroy(): void {
this.emitters.removeEmitter(this);

tsParticles.dispatchEvent("emitterDestroyed", {
container: this.container,
data: {
emitter: this
}
});
}

private calcPosition(): ICoordinates {
Expand Down
6 changes: 5 additions & 1 deletion plugins/polygonMask/src/PolygonMaskInstance.ts
@@ -1,4 +1,4 @@
import type { Container } from "tsparticles-engine";
import { Container, tsParticles } from "tsparticles-engine";
import type { IContainerPlugin, ICoordinates, IDelta, IDimension } from "tsparticles-engine";
import { InlineArrangement, Type } from "./Enums";
import { Particle } from "tsparticles-engine";
Expand Down Expand Up @@ -519,5 +519,9 @@ export class PolygonMaskInstance implements IContainerPlugin {
}

this.createPath2D();

tsParticles.dispatchEvent("polygonMaskLoaded", {
container: this.container
});
}
}

0 comments on commit cea5ed6

Please sign in to comment.