@tsparticles/slim 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v3.0.1
7
+ * v3.0.2
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -3900,6 +3900,12 @@ class Particle {
3900
3900
  updater.particleDestroyed && updater.particleDestroyed(this, override);
3901
3901
  }
3902
3902
  pathGenerator && pathGenerator.reset(this);
3903
+ this._engine.dispatchEvent("particleDestroyed", {
3904
+ container: this.container,
3905
+ data: {
3906
+ particle: this
3907
+ }
3908
+ });
3903
3909
  }
3904
3910
  draw(delta) {
3905
3911
  const container = this.container,
@@ -4252,6 +4258,11 @@ const qTreeRectangle = canvasSize => {
4252
4258
  };
4253
4259
  class Particles {
4254
4260
  constructor(engine, container) {
4261
+ this._addToPool = (...particles) => {
4262
+ for (const particle of particles) {
4263
+ this._pool.push(particle);
4264
+ }
4265
+ };
4255
4266
  this._applyDensity = (options, manualCount, group) => {
4256
4267
  const numberOptions = options.number;
4257
4268
  if (!options.number.density?.enable) {
@@ -4322,17 +4333,17 @@ class Particles {
4322
4333
  if (!particle || particle.group !== group) {
4323
4334
  return false;
4324
4335
  }
4325
- particle.destroy(override);
4326
4336
  const zIdx = this._zArray.indexOf(particle);
4327
4337
  this._array.splice(index, 1);
4328
4338
  this._zArray.splice(zIdx, 1);
4329
- this._pool.push(particle);
4339
+ particle.destroy(override);
4330
4340
  this._engine.dispatchEvent("particleRemoved", {
4331
4341
  container: this._container,
4332
4342
  data: {
4333
4343
  particle
4334
4344
  }
4335
4345
  });
4346
+ this._addToPool(particle);
4336
4347
  return true;
4337
4348
  };
4338
4349
  this._engine = engine;
@@ -4530,7 +4541,15 @@ class Particles {
4530
4541
  const checkDelete = p => !particlesToDelete.has(p);
4531
4542
  this._array = this.filter(checkDelete);
4532
4543
  this._zArray = this._zArray.filter(checkDelete);
4533
- this._pool.push(...particlesToDelete);
4544
+ for (const particle of particlesToDelete) {
4545
+ this._engine.dispatchEvent("particleRemoved", {
4546
+ container: this._container,
4547
+ data: {
4548
+ particle
4549
+ }
4550
+ });
4551
+ }
4552
+ this._addToPool(...particlesToDelete);
4534
4553
  }
4535
4554
  await this._interactionManager.externalInteract(delta);
4536
4555
  for (const particle of this._array) {
@@ -5146,7 +5165,7 @@ class Engine {
5146
5165
  return res;
5147
5166
  }
5148
5167
  get version() {
5149
- return "3.0.1";
5168
+ return "3.0.2";
5150
5169
  }
5151
5170
  addConfig(config) {
5152
5171
  const name = config.name ?? "default";