@tsparticles/plugin-infection 3.0.3 → 3.1.0

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.
@@ -1,3 +1,5 @@
1
+ import { millisecondsToSeconds } from "@tsparticles/engine";
2
+ const minStage = 0, minDuration = 0;
1
3
  export class Infecter {
2
4
  constructor(container) {
3
5
  this._nextInfectionStage = (particle) => {
@@ -6,7 +8,7 @@ export class Infecter {
6
8
  return;
7
9
  }
8
10
  const stagesCount = infectionOptions.stages.length;
9
- if (stagesCount <= 0 || infection.stage === undefined) {
11
+ if (stagesCount <= minStage || infection.stage === undefined) {
10
12
  return;
11
13
  }
12
14
  infection.time = 0;
@@ -14,7 +16,6 @@ export class Infecter {
14
16
  if (infectionOptions.cure) {
15
17
  delete infection.stage;
16
18
  delete infection.time;
17
- return;
18
19
  }
19
20
  else {
20
21
  infection.stage = 0;
@@ -30,7 +31,7 @@ export class Infecter {
30
31
  return;
31
32
  }
32
33
  const stages = infectionOptions.stages, stagesCount = stages.length;
33
- if (stage > stagesCount || stage < 0) {
34
+ if (stage > stagesCount || stage < minStage) {
34
35
  return;
35
36
  }
36
37
  infection.delay = 0;
@@ -44,10 +45,10 @@ export class Infecter {
44
45
  const stages = infectionOptions.stages, stagesCount = stages.length;
45
46
  if (infection.delay !== undefined && infection.delayStage !== undefined) {
46
47
  const stage = infection.delayStage;
47
- if (stage > stagesCount || stage < 0) {
48
+ if (stage > stagesCount || stage < minStage) {
48
49
  return;
49
50
  }
50
- if (infection.delay >= infectionOptions.delay * 1000) {
51
+ if (infection.delay >= infectionOptions.delay * millisecondsToSeconds) {
51
52
  infection.stage = stage;
52
53
  infection.time = 0;
53
54
  delete infection.delay;
@@ -63,8 +64,8 @@ export class Infecter {
63
64
  }
64
65
  if (infection.stage !== undefined && infection.time !== undefined) {
65
66
  const infectionStage = stages[infection.stage];
66
- if (infectionStage.duration !== undefined && infectionStage.duration >= 0) {
67
- if (infection.time > infectionStage.duration * 1000) {
67
+ if (infectionStage.duration !== undefined && infectionStage.duration >= minDuration) {
68
+ if (infection.time > infectionStage.duration * millisecondsToSeconds) {
68
69
  this._nextInfectionStage(particle);
69
70
  }
70
71
  else {
@@ -86,7 +87,7 @@ export class Infecter {
86
87
  return;
87
88
  }
88
89
  const stagesCount = options.infection.stages.length;
89
- if (stage > stagesCount || stage < 0 || (infection.stage !== undefined && infection.stage > stage)) {
90
+ if (stage > stagesCount || stage < minStage || (infection.stage !== undefined && infection.stage > stage)) {
90
91
  return;
91
92
  }
92
93
  infection.stage = stage;
@@ -1,5 +1,6 @@
1
1
  import { itemFromArray } from "@tsparticles/engine";
2
2
  import { Infecter } from "./Infecter.js";
3
+ const minStage = 0;
3
4
  export class InfectionInstance {
4
5
  constructor(container) {
5
6
  this._container = container;
@@ -30,7 +31,7 @@ export class InfectionInstance {
30
31
  return infP.infection.stage === undefined;
31
32
  });
32
33
  const infected = itemFromArray(notInfected);
33
- this._container.infecter?.startInfection(infected, 0);
34
+ this._container.infecter?.startInfection(infected, minStage);
34
35
  }
35
36
  }
36
37
  }
@@ -1,4 +1,5 @@
1
1
  import { ParticlesInteractorBase, getRandom } from "@tsparticles/engine";
2
+ const minStagesCount = 1, double = 2;
2
3
  export class ParticlesInfecter extends ParticlesInteractorBase {
3
4
  constructor(container) {
4
5
  super(container);
@@ -17,10 +18,10 @@ export class ParticlesInfecter extends ParticlesInteractorBase {
17
18
  return;
18
19
  }
19
20
  const container = this.container, options = container.actualOptions, infectionOptions = options.infection;
20
- if (!infectionOptions?.enable || infectionOptions.stages.length < 1) {
21
+ if (!infectionOptions?.enable || infectionOptions.stages.length < minStagesCount) {
21
22
  return;
22
23
  }
23
- const infectionStage1 = infectionOptions.stages[p1.infection.stage], pxRatio = container.retina.pixelRatio, radius = p1.getRadius() * 2 + infectionStage1.radius * pxRatio, pos = p1.getPosition(), infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage, query = container.particles.quadTree.queryCircle(pos, radius), infections = infectionStage1.rate, neighbors = query.length;
24
+ const infectionStage1 = infectionOptions.stages[p1.infection.stage], pxRatio = container.retina.pixelRatio, radius = p1.getRadius() * double + infectionStage1.radius * pxRatio, pos = p1.getPosition(), infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage, query = container.particles.quadTree.queryCircle(pos, radius), infections = infectionStage1.rate, neighbors = query.length;
24
25
  for (const p2 of query) {
25
26
  const infP2 = p2;
26
27
  if (infP2 === p1 ||
@@ -42,6 +43,7 @@ export class ParticlesInfecter extends ParticlesInteractorBase {
42
43
  infecter.updateInfectionStage(p1, infectedStage2);
43
44
  }
44
45
  }
46
+ await Promise.resolve();
45
47
  }
46
48
  isEnabled() {
47
49
  return this.container.actualOptions?.infection?.enable ?? false;
package/cjs/Infecter.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Infecter = void 0;
4
+ const engine_1 = require("@tsparticles/engine");
5
+ const minStage = 0, minDuration = 0;
4
6
  class Infecter {
5
7
  constructor(container) {
6
8
  this._nextInfectionStage = (particle) => {
@@ -9,7 +11,7 @@ class Infecter {
9
11
  return;
10
12
  }
11
13
  const stagesCount = infectionOptions.stages.length;
12
- if (stagesCount <= 0 || infection.stage === undefined) {
14
+ if (stagesCount <= minStage || infection.stage === undefined) {
13
15
  return;
14
16
  }
15
17
  infection.time = 0;
@@ -17,7 +19,6 @@ class Infecter {
17
19
  if (infectionOptions.cure) {
18
20
  delete infection.stage;
19
21
  delete infection.time;
20
- return;
21
22
  }
22
23
  else {
23
24
  infection.stage = 0;
@@ -33,7 +34,7 @@ class Infecter {
33
34
  return;
34
35
  }
35
36
  const stages = infectionOptions.stages, stagesCount = stages.length;
36
- if (stage > stagesCount || stage < 0) {
37
+ if (stage > stagesCount || stage < minStage) {
37
38
  return;
38
39
  }
39
40
  infection.delay = 0;
@@ -47,10 +48,10 @@ class Infecter {
47
48
  const stages = infectionOptions.stages, stagesCount = stages.length;
48
49
  if (infection.delay !== undefined && infection.delayStage !== undefined) {
49
50
  const stage = infection.delayStage;
50
- if (stage > stagesCount || stage < 0) {
51
+ if (stage > stagesCount || stage < minStage) {
51
52
  return;
52
53
  }
53
- if (infection.delay >= infectionOptions.delay * 1000) {
54
+ if (infection.delay >= infectionOptions.delay * engine_1.millisecondsToSeconds) {
54
55
  infection.stage = stage;
55
56
  infection.time = 0;
56
57
  delete infection.delay;
@@ -66,8 +67,8 @@ class Infecter {
66
67
  }
67
68
  if (infection.stage !== undefined && infection.time !== undefined) {
68
69
  const infectionStage = stages[infection.stage];
69
- if (infectionStage.duration !== undefined && infectionStage.duration >= 0) {
70
- if (infection.time > infectionStage.duration * 1000) {
70
+ if (infectionStage.duration !== undefined && infectionStage.duration >= minDuration) {
71
+ if (infection.time > infectionStage.duration * engine_1.millisecondsToSeconds) {
71
72
  this._nextInfectionStage(particle);
72
73
  }
73
74
  else {
@@ -89,7 +90,7 @@ class Infecter {
89
90
  return;
90
91
  }
91
92
  const stagesCount = options.infection.stages.length;
92
- if (stage > stagesCount || stage < 0 || (infection.stage !== undefined && infection.stage > stage)) {
93
+ if (stage > stagesCount || stage < minStage || (infection.stage !== undefined && infection.stage > stage)) {
93
94
  return;
94
95
  }
95
96
  infection.stage = stage;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InfectionInstance = void 0;
4
4
  const engine_1 = require("@tsparticles/engine");
5
5
  const Infecter_js_1 = require("./Infecter.js");
6
+ const minStage = 0;
6
7
  class InfectionInstance {
7
8
  constructor(container) {
8
9
  this._container = container;
@@ -33,7 +34,7 @@ class InfectionInstance {
33
34
  return infP.infection.stage === undefined;
34
35
  });
35
36
  const infected = (0, engine_1.itemFromArray)(notInfected);
36
- this._container.infecter?.startInfection(infected, 0);
37
+ this._container.infecter?.startInfection(infected, minStage);
37
38
  }
38
39
  }
39
40
  }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ParticlesInfecter = void 0;
4
4
  const engine_1 = require("@tsparticles/engine");
5
+ const minStagesCount = 1, double = 2;
5
6
  class ParticlesInfecter extends engine_1.ParticlesInteractorBase {
6
7
  constructor(container) {
7
8
  super(container);
@@ -20,10 +21,10 @@ class ParticlesInfecter extends engine_1.ParticlesInteractorBase {
20
21
  return;
21
22
  }
22
23
  const container = this.container, options = container.actualOptions, infectionOptions = options.infection;
23
- if (!infectionOptions?.enable || infectionOptions.stages.length < 1) {
24
+ if (!infectionOptions?.enable || infectionOptions.stages.length < minStagesCount) {
24
25
  return;
25
26
  }
26
- const infectionStage1 = infectionOptions.stages[p1.infection.stage], pxRatio = container.retina.pixelRatio, radius = p1.getRadius() * 2 + infectionStage1.radius * pxRatio, pos = p1.getPosition(), infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage, query = container.particles.quadTree.queryCircle(pos, radius), infections = infectionStage1.rate, neighbors = query.length;
27
+ const infectionStage1 = infectionOptions.stages[p1.infection.stage], pxRatio = container.retina.pixelRatio, radius = p1.getRadius() * double + infectionStage1.radius * pxRatio, pos = p1.getPosition(), infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage, query = container.particles.quadTree.queryCircle(pos, radius), infections = infectionStage1.rate, neighbors = query.length;
27
28
  for (const p2 of query) {
28
29
  const infP2 = p2;
29
30
  if (infP2 === p1 ||
@@ -45,6 +46,7 @@ class ParticlesInfecter extends engine_1.ParticlesInteractorBase {
45
46
  infecter.updateInfectionStage(p1, infectedStage2);
46
47
  }
47
48
  }
49
+ await Promise.resolve();
48
50
  }
49
51
  isEnabled() {
50
52
  return this.container.actualOptions?.infection?.enable ?? false;
package/esm/Infecter.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { millisecondsToSeconds } from "@tsparticles/engine";
2
+ const minStage = 0, minDuration = 0;
1
3
  export class Infecter {
2
4
  constructor(container) {
3
5
  this._nextInfectionStage = (particle) => {
@@ -6,7 +8,7 @@ export class Infecter {
6
8
  return;
7
9
  }
8
10
  const stagesCount = infectionOptions.stages.length;
9
- if (stagesCount <= 0 || infection.stage === undefined) {
11
+ if (stagesCount <= minStage || infection.stage === undefined) {
10
12
  return;
11
13
  }
12
14
  infection.time = 0;
@@ -14,7 +16,6 @@ export class Infecter {
14
16
  if (infectionOptions.cure) {
15
17
  delete infection.stage;
16
18
  delete infection.time;
17
- return;
18
19
  }
19
20
  else {
20
21
  infection.stage = 0;
@@ -30,7 +31,7 @@ export class Infecter {
30
31
  return;
31
32
  }
32
33
  const stages = infectionOptions.stages, stagesCount = stages.length;
33
- if (stage > stagesCount || stage < 0) {
34
+ if (stage > stagesCount || stage < minStage) {
34
35
  return;
35
36
  }
36
37
  infection.delay = 0;
@@ -44,10 +45,10 @@ export class Infecter {
44
45
  const stages = infectionOptions.stages, stagesCount = stages.length;
45
46
  if (infection.delay !== undefined && infection.delayStage !== undefined) {
46
47
  const stage = infection.delayStage;
47
- if (stage > stagesCount || stage < 0) {
48
+ if (stage > stagesCount || stage < minStage) {
48
49
  return;
49
50
  }
50
- if (infection.delay >= infectionOptions.delay * 1000) {
51
+ if (infection.delay >= infectionOptions.delay * millisecondsToSeconds) {
51
52
  infection.stage = stage;
52
53
  infection.time = 0;
53
54
  delete infection.delay;
@@ -63,8 +64,8 @@ export class Infecter {
63
64
  }
64
65
  if (infection.stage !== undefined && infection.time !== undefined) {
65
66
  const infectionStage = stages[infection.stage];
66
- if (infectionStage.duration !== undefined && infectionStage.duration >= 0) {
67
- if (infection.time > infectionStage.duration * 1000) {
67
+ if (infectionStage.duration !== undefined && infectionStage.duration >= minDuration) {
68
+ if (infection.time > infectionStage.duration * millisecondsToSeconds) {
68
69
  this._nextInfectionStage(particle);
69
70
  }
70
71
  else {
@@ -86,7 +87,7 @@ export class Infecter {
86
87
  return;
87
88
  }
88
89
  const stagesCount = options.infection.stages.length;
89
- if (stage > stagesCount || stage < 0 || (infection.stage !== undefined && infection.stage > stage)) {
90
+ if (stage > stagesCount || stage < minStage || (infection.stage !== undefined && infection.stage > stage)) {
90
91
  return;
91
92
  }
92
93
  infection.stage = stage;
@@ -1,5 +1,6 @@
1
1
  import { itemFromArray } from "@tsparticles/engine";
2
2
  import { Infecter } from "./Infecter.js";
3
+ const minStage = 0;
3
4
  export class InfectionInstance {
4
5
  constructor(container) {
5
6
  this._container = container;
@@ -30,7 +31,7 @@ export class InfectionInstance {
30
31
  return infP.infection.stage === undefined;
31
32
  });
32
33
  const infected = itemFromArray(notInfected);
33
- this._container.infecter?.startInfection(infected, 0);
34
+ this._container.infecter?.startInfection(infected, minStage);
34
35
  }
35
36
  }
36
37
  }
@@ -1,4 +1,5 @@
1
1
  import { ParticlesInteractorBase, getRandom } from "@tsparticles/engine";
2
+ const minStagesCount = 1, double = 2;
2
3
  export class ParticlesInfecter extends ParticlesInteractorBase {
3
4
  constructor(container) {
4
5
  super(container);
@@ -17,10 +18,10 @@ export class ParticlesInfecter extends ParticlesInteractorBase {
17
18
  return;
18
19
  }
19
20
  const container = this.container, options = container.actualOptions, infectionOptions = options.infection;
20
- if (!infectionOptions?.enable || infectionOptions.stages.length < 1) {
21
+ if (!infectionOptions?.enable || infectionOptions.stages.length < minStagesCount) {
21
22
  return;
22
23
  }
23
- const infectionStage1 = infectionOptions.stages[p1.infection.stage], pxRatio = container.retina.pixelRatio, radius = p1.getRadius() * 2 + infectionStage1.radius * pxRatio, pos = p1.getPosition(), infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage, query = container.particles.quadTree.queryCircle(pos, radius), infections = infectionStage1.rate, neighbors = query.length;
24
+ const infectionStage1 = infectionOptions.stages[p1.infection.stage], pxRatio = container.retina.pixelRatio, radius = p1.getRadius() * double + infectionStage1.radius * pxRatio, pos = p1.getPosition(), infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage, query = container.particles.quadTree.queryCircle(pos, radius), infections = infectionStage1.rate, neighbors = query.length;
24
25
  for (const p2 of query) {
25
26
  const infP2 = p2;
26
27
  if (infP2 === p1 ||
@@ -42,6 +43,7 @@ export class ParticlesInfecter extends ParticlesInteractorBase {
42
43
  infecter.updateInfectionStage(p1, infectedStage2);
43
44
  }
44
45
  }
46
+ await Promise.resolve();
45
47
  }
46
48
  isEnabled() {
47
49
  return this.container.actualOptions?.infection?.enable ?? false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/plugin-infection",
3
- "version": "3.0.3",
3
+ "version": "3.1.0",
4
4
  "description": "tsParticles infection plugin",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -100,7 +100,7 @@
100
100
  "./package.json": "./package.json"
101
101
  },
102
102
  "dependencies": {
103
- "@tsparticles/engine": "^3.0.3"
103
+ "@tsparticles/engine": "^3.1.0"
104
104
  },
105
105
  "publishConfig": {
106
106
  "access": "public"
package/report.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8"/>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
- <title>@tsparticles/plugin-infection [26 Dec 2023 at 19:29]</title>
6
+ <title>@tsparticles/plugin-infection [13 Jan 2024 at 23:05]</title>
7
7
  <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
8
8
 
9
9
  <script>
@@ -31,7 +31,7 @@
31
31
  <body>
32
32
  <div id="app"></div>
33
33
  <script>
34
- window.chartData = [{"label":"tsparticles.plugin.infection.js","isAsset":true,"statSize":8773,"parsedSize":12446,"gzipSize":3005,"groups":[{"label":"dist/browser","path":"./dist/browser","statSize":8731,"groups":[{"id":222,"label":"index.js + 5 modules (concatenated)","path":"./dist/browser/index.js + 5 modules (concatenated)","statSize":8731,"parsedSize":12446,"gzipSize":3005,"concatenated":true,"groups":[{"label":"dist/browser","path":"./dist/browser/index.js + 5 modules (concatenated)/dist/browser","statSize":8731,"groups":[{"id":null,"label":"index.js","path":"./dist/browser/index.js + 5 modules (concatenated)/dist/browser/index.js","statSize":1107,"parsedSize":1578,"gzipSize":381,"inaccurateSizes":true},{"id":null,"label":"InfectionInstance.js","path":"./dist/browser/index.js + 5 modules (concatenated)/dist/browser/InfectionInstance.js","statSize":1251,"parsedSize":1783,"gzipSize":430,"inaccurateSizes":true},{"label":"Options/Classes","path":"./dist/browser/index.js + 5 modules (concatenated)/dist/browser/Options/Classes","statSize":1387,"groups":[{"id":null,"label":"Infection.js","path":"./dist/browser/index.js + 5 modules (concatenated)/dist/browser/Options/Classes/Infection.js","statSize":770,"parsedSize":1097,"gzipSize":265,"inaccurateSizes":true},{"id":null,"label":"InfectionStage.js","path":"./dist/browser/index.js + 5 modules (concatenated)/dist/browser/Options/Classes/InfectionStage.js","statSize":617,"parsedSize":879,"gzipSize":212,"inaccurateSizes":true}],"parsedSize":1977,"gzipSize":477,"inaccurateSizes":true},{"id":null,"label":"ParticlesInfecter.js","path":"./dist/browser/index.js + 5 modules (concatenated)/dist/browser/ParticlesInfecter.js","statSize":2017,"parsedSize":2875,"gzipSize":694,"inaccurateSizes":true},{"id":null,"label":"Infecter.js","path":"./dist/browser/index.js + 5 modules (concatenated)/dist/browser/Infecter.js","statSize":2969,"parsedSize":4232,"gzipSize":1021,"inaccurateSizes":true}],"parsedSize":12446,"gzipSize":3005,"inaccurateSizes":true}]}],"parsedSize":12446,"gzipSize":3005},{"label":"engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","statSize":42,"groups":[{"id":533,"label":"engine\",\"root\":\"window\"}","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles/engine\",\"root\":\"window\"}","statSize":42}],"parsedSize":0,"gzipSize":0}],"isInitialByEntrypoint":{"tsparticles.plugin.infection":true}}];
34
+ window.chartData = [{"label":"tsparticles.plugin.infection.js","isAsset":true,"statSize":9041,"parsedSize":12766,"gzipSize":3081,"groups":[{"label":"dist/browser","path":"./dist/browser","statSize":8999,"groups":[{"id":592,"label":"index.js + 5 modules (concatenated)","path":"./dist/browser/index.js + 5 modules (concatenated)","statSize":8999,"parsedSize":12766,"gzipSize":3081,"concatenated":true,"groups":[{"label":"dist/browser","path":"./dist/browser/index.js + 5 modules (concatenated)/dist/browser","statSize":8999,"groups":[{"id":null,"label":"index.js","path":"./dist/browser/index.js + 5 modules (concatenated)/dist/browser/index.js","statSize":1107,"parsedSize":1570,"gzipSize":379,"inaccurateSizes":true},{"id":null,"label":"InfectionInstance.js","path":"./dist/browser/index.js + 5 modules (concatenated)/dist/browser/InfectionInstance.js","statSize":1278,"parsedSize":1812,"gzipSize":437,"inaccurateSizes":true},{"label":"Options/Classes","path":"./dist/browser/index.js + 5 modules (concatenated)/dist/browser/Options/Classes","statSize":1387,"groups":[{"id":null,"label":"Infection.js","path":"./dist/browser/index.js + 5 modules (concatenated)/dist/browser/Options/Classes/Infection.js","statSize":770,"parsedSize":1092,"gzipSize":263,"inaccurateSizes":true},{"id":null,"label":"InfectionStage.js","path":"./dist/browser/index.js + 5 modules (concatenated)/dist/browser/Options/Classes/InfectionStage.js","statSize":617,"parsedSize":875,"gzipSize":211,"inaccurateSizes":true}],"parsedSize":1967,"gzipSize":474,"inaccurateSizes":true},{"id":null,"label":"ParticlesInfecter.js","path":"./dist/browser/index.js + 5 modules (concatenated)/dist/browser/ParticlesInfecter.js","statSize":2104,"parsedSize":2984,"gzipSize":720,"inaccurateSizes":true},{"id":null,"label":"Infecter.js","path":"./dist/browser/index.js + 5 modules (concatenated)/dist/browser/Infecter.js","statSize":3123,"parsedSize":4430,"gzipSize":1069,"inaccurateSizes":true}],"parsedSize":12766,"gzipSize":3081,"inaccurateSizes":true}]}],"parsedSize":12766,"gzipSize":3081},{"label":"engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","statSize":42,"groups":[{"id":533,"label":"engine\",\"root\":\"window\"}","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles/engine\",\"root\":\"window\"}","statSize":42}],"parsedSize":0,"gzipSize":0}],"isInitialByEntrypoint":{"tsparticles.plugin.infection":true}}];
35
35
  window.entrypoints = ["tsparticles.plugin.infection","tsparticles.plugin.infection.min"];
36
36
  window.defaultSizes = "parsed";
37
37
  </script>
@@ -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.3
7
+ * v3.1.0
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -159,6 +159,9 @@ class Infection {
159
159
  }
160
160
  }
161
161
  ;// CONCATENATED MODULE: ./dist/browser/Infecter.js
162
+
163
+ const minStage = 0,
164
+ minDuration = 0;
162
165
  class Infecter {
163
166
  constructor(container) {
164
167
  this._nextInfectionStage = particle => {
@@ -170,7 +173,7 @@ class Infecter {
170
173
  return;
171
174
  }
172
175
  const stagesCount = infectionOptions.stages.length;
173
- if (stagesCount <= 0 || infection.stage === undefined) {
176
+ if (stagesCount <= minStage || infection.stage === undefined) {
174
177
  return;
175
178
  }
176
179
  infection.time = 0;
@@ -178,7 +181,6 @@ class Infecter {
178
181
  if (infectionOptions.cure) {
179
182
  delete infection.stage;
180
183
  delete infection.time;
181
- return;
182
184
  } else {
183
185
  infection.stage = 0;
184
186
  infection.time = 0;
@@ -197,7 +199,7 @@ class Infecter {
197
199
  }
198
200
  const stages = infectionOptions.stages,
199
201
  stagesCount = stages.length;
200
- if (stage > stagesCount || stage < 0) {
202
+ if (stage > stagesCount || stage < minStage) {
201
203
  return;
202
204
  }
203
205
  infection.delay = 0;
@@ -215,10 +217,10 @@ class Infecter {
215
217
  stagesCount = stages.length;
216
218
  if (infection.delay !== undefined && infection.delayStage !== undefined) {
217
219
  const stage = infection.delayStage;
218
- if (stage > stagesCount || stage < 0) {
220
+ if (stage > stagesCount || stage < minStage) {
219
221
  return;
220
222
  }
221
- if (infection.delay >= infectionOptions.delay * 1000) {
223
+ if (infection.delay >= infectionOptions.delay * engine_root_window_.millisecondsToSeconds) {
222
224
  infection.stage = stage;
223
225
  infection.time = 0;
224
226
  delete infection.delay;
@@ -232,8 +234,8 @@ class Infecter {
232
234
  }
233
235
  if (infection.stage !== undefined && infection.time !== undefined) {
234
236
  const infectionStage = stages[infection.stage];
235
- if (infectionStage.duration !== undefined && infectionStage.duration >= 0) {
236
- if (infection.time > infectionStage.duration * 1000) {
237
+ if (infectionStage.duration !== undefined && infectionStage.duration >= minDuration) {
238
+ if (infection.time > infectionStage.duration * engine_root_window_.millisecondsToSeconds) {
237
239
  this._nextInfectionStage(particle);
238
240
  } else {
239
241
  infection.time += delta;
@@ -255,7 +257,7 @@ class Infecter {
255
257
  return;
256
258
  }
257
259
  const stagesCount = options.infection.stages.length;
258
- if (stage > stagesCount || stage < 0 || infection.stage !== undefined && infection.stage > stage) {
260
+ if (stage > stagesCount || stage < minStage || infection.stage !== undefined && infection.stage > stage) {
259
261
  return;
260
262
  }
261
263
  infection.stage = stage;
@@ -265,6 +267,7 @@ class Infecter {
265
267
  ;// CONCATENATED MODULE: ./dist/browser/InfectionInstance.js
266
268
 
267
269
 
270
+ const InfectionInstance_minStage = 0;
268
271
  class InfectionInstance {
269
272
  constructor(container) {
270
273
  this._container = container;
@@ -297,12 +300,14 @@ class InfectionInstance {
297
300
  return infP.infection.stage === undefined;
298
301
  });
299
302
  const infected = (0,engine_root_window_.itemFromArray)(notInfected);
300
- this._container.infecter?.startInfection(infected, 0);
303
+ this._container.infecter?.startInfection(infected, InfectionInstance_minStage);
301
304
  }
302
305
  }
303
306
  }
304
307
  ;// CONCATENATED MODULE: ./dist/browser/ParticlesInfecter.js
305
308
 
309
+ const minStagesCount = 1,
310
+ ParticlesInfecter_double = 2;
306
311
  class ParticlesInfecter extends engine_root_window_.ParticlesInteractorBase {
307
312
  constructor(container) {
308
313
  super(container);
@@ -321,12 +326,12 @@ class ParticlesInfecter extends engine_root_window_.ParticlesInteractorBase {
321
326
  const container = this.container,
322
327
  options = container.actualOptions,
323
328
  infectionOptions = options.infection;
324
- if (!infectionOptions?.enable || infectionOptions.stages.length < 1) {
329
+ if (!infectionOptions?.enable || infectionOptions.stages.length < minStagesCount) {
325
330
  return;
326
331
  }
327
332
  const infectionStage1 = infectionOptions.stages[p1.infection.stage],
328
333
  pxRatio = container.retina.pixelRatio,
329
- radius = p1.getRadius() * 2 + infectionStage1.radius * pxRatio,
334
+ radius = p1.getRadius() * ParticlesInfecter_double + infectionStage1.radius * pxRatio,
330
335
  pos = p1.getPosition(),
331
336
  infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage,
332
337
  query = container.particles.quadTree.queryCircle(pos, radius),
@@ -347,6 +352,7 @@ class ParticlesInfecter extends engine_root_window_.ParticlesInteractorBase {
347
352
  infecter.updateInfectionStage(p1, infectedStage2);
348
353
  }
349
354
  }
355
+ await Promise.resolve();
350
356
  }
351
357
  isEnabled() {
352
358
  return this.container.actualOptions?.infection?.enable ?? false;
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.plugin.infection.min.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var i="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var n in i)("object"==typeof exports?exports:e)[n]=i[n]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},i={};function n(e){var o=i[e];if(void 0!==o)return o.exports;var s=i[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{loadInfectionPlugin:()=>l});var e=n(533);class t{constructor(){this.color=new e.OptionsColor,this.color.value="#ff0000",this.radius=0,this.rate=1}load(t){void 0!==t&&(void 0!==t.color&&(this.color=e.OptionsColor.create(this.color,t.color)),this.duration=t.duration,this.infectedStage=t.infectedStage,void 0!==t.radius&&(this.radius=t.radius),void 0!==t.rate&&(this.rate=t.rate))}}class i{constructor(){this.cure=!1,this.delay=0,this.enable=!1,this.infections=0,this.stages=[]}load(e){void 0!==e&&(void 0!==e.cure&&(this.cure=e.cure),void 0!==e.delay&&(this.delay=e.delay),void 0!==e.enable&&(this.enable=e.enable),void 0!==e.infections&&(this.infections=e.infections),void 0!==e.stages&&(this.stages=e.stages.map((e=>{const i=new t;return i.load(e),i}))))}}class s{constructor(e){this._nextInfectionStage=e=>{const t=this._container.actualOptions.infection,{infection:i}=e;if(!t||!i)return;const n=t.stages.length;if(!(n<=0||void 0===i.stage)&&(i.time=0,n<=++i.stage)){if(t.cure)return delete i.stage,void delete i.time;i.stage=0,i.time=0}},this._container=e}startInfection(e,t){const i=this._container.actualOptions.infection,{infection:n}=e;if(!i||!n)return;t>i.stages.length||t<0||(n.delay=0,n.delayStage=t)}updateInfection(e,t){const i=this._container.actualOptions.infection,{infection:n}=e;if(!i||!n)return;const o=i.stages,s=o.length;if(void 0!==n.delay&&void 0!==n.delayStage){const e=n.delayStage;if(e>s||e<0)return;n.delay>=1e3*i.delay?(n.stage=e,n.time=0,delete n.delay,delete n.delayStage):n.delay+=t}else delete n.delay,delete n.delayStage;if(void 0!==n.stage&&void 0!==n.time){const i=o[n.stage];void 0!==i.duration&&i.duration>=0&&n.time>1e3*i.duration?this._nextInfectionStage(e):n.time+=t}else delete n.stage,delete n.time}updateInfectionStage(e,t){const i=this._container.actualOptions,{infection:n}=e;if(!i.infection||!n)return;t>i.infection.stages.length||t<0||void 0!==n.stage&&n.stage>t||(n.stage=t,n.time=0)}}class a{constructor(e){this._container=e,this._container.infecter=new s(this._container)}particleFillColor(e){const t=this._container.actualOptions;if(!e.infection||!t.infection)return;const i=e.infection.stage,n=t.infection.stages;return void 0!==i?n[i].color:void 0}particleStrokeColor(e){return this.particleFillColor(e)}particlesSetup(){const t=this._container.actualOptions;if(t.infection)for(let i=0;i<t.infection.infections;i++){const t=this._container.particles.filter((e=>{const t=e;return t.infection||(t.infection={}),void 0===t.infection.stage})),i=(0,e.itemFromArray)(t);this._container.infecter?.startInfection(i,0)}}}class r extends e.ParticlesInteractorBase{constructor(e){super(e)}clear(){}init(){}async interact(t,i){const n=this.container.infecter;if(!n)return;if(n.updateInfection(t,i.value),void 0===t.infection?.stage)return;const o=this.container,s=o.actualOptions.infection;if(!s?.enable||s.stages.length<1)return;const a=s.stages[t.infection.stage],r=o.retina.pixelRatio,c=2*t.getRadius()+a.radius*r,l=t.getPosition(),f=a.infectedStage??t.infection.stage,d=o.particles.quadTree.queryCircle(l,c),u=a.rate,g=d.length;for(const i of d){const o=i;if(!(o===t||o.destroyed||o.spawning||void 0!==o.infection?.stage&&o.infection.stage===t.infection.stage||(0,e.getRandom)()>=u/g))if(void 0===o.infection?.stage)n.startInfection(o,f);else if(o.infection.stage<t.infection.stage)n.updateInfectionStage(o,f);else if(o.infection.stage>t.infection.stage){const e=s.stages[o.infection.stage],i=e?.infectedStage??o.infection.stage;n.updateInfectionStage(t,i)}}}isEnabled(){return this.container.actualOptions?.infection?.enable??!1}reset(){}}class c{constructor(){this.id="infection"}getPlugin(e){return new a(e)}loadOptions(e,t){if(!this.needsPlugin(e)&&!this.needsPlugin(t))return;let n=e.infection;void 0===n?.load&&(e.infection=n=new i),n.load(t?.infection)}needsPlugin(e){return e?.infection?.enable??!1}}async function l(e,t=!0){const i=new c;await e.addPlugin(i,t),await e.addInteractor("particlesInfection",(e=>new r(e)),t)}})(),o})()));
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var i="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var n in i)("object"==typeof exports?exports:e)[n]=i[n]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},i={};function n(e){var o=i[e];if(void 0!==o)return o.exports;var s=i[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{loadInfectionPlugin:()=>l});var e=n(533);class t{constructor(){this.color=new e.OptionsColor,this.color.value="#ff0000",this.radius=0,this.rate=1}load(t){void 0!==t&&(void 0!==t.color&&(this.color=e.OptionsColor.create(this.color,t.color)),this.duration=t.duration,this.infectedStage=t.infectedStage,void 0!==t.radius&&(this.radius=t.radius),void 0!==t.rate&&(this.rate=t.rate))}}class i{constructor(){this.cure=!1,this.delay=0,this.enable=!1,this.infections=0,this.stages=[]}load(e){void 0!==e&&(void 0!==e.cure&&(this.cure=e.cure),void 0!==e.delay&&(this.delay=e.delay),void 0!==e.enable&&(this.enable=e.enable),void 0!==e.infections&&(this.infections=e.infections),void 0!==e.stages&&(this.stages=e.stages.map((e=>{const i=new t;return i.load(e),i}))))}}class s{constructor(e){this._nextInfectionStage=e=>{const t=this._container.actualOptions.infection,{infection:i}=e;if(!t||!i)return;const n=t.stages.length;n<=0||void 0===i.stage||(i.time=0,n<=++i.stage&&(t.cure?(delete i.stage,delete i.time):(i.stage=0,i.time=0)))},this._container=e}startInfection(e,t){const i=this._container.actualOptions.infection,{infection:n}=e;if(!i||!n)return;t>i.stages.length||t<0||(n.delay=0,n.delayStage=t)}updateInfection(t,i){const n=this._container.actualOptions.infection,{infection:o}=t;if(!n||!o)return;const s=n.stages,a=s.length;if(void 0!==o.delay&&void 0!==o.delayStage){const t=o.delayStage;if(t>a||t<0)return;o.delay>=n.delay*e.millisecondsToSeconds?(o.stage=t,o.time=0,delete o.delay,delete o.delayStage):o.delay+=i}else delete o.delay,delete o.delayStage;if(void 0!==o.stage&&void 0!==o.time){const n=s[o.stage];void 0!==n.duration&&n.duration>=0&&o.time>n.duration*e.millisecondsToSeconds?this._nextInfectionStage(t):o.time+=i}else delete o.stage,delete o.time}updateInfectionStage(e,t){const i=this._container.actualOptions,{infection:n}=e;if(!i.infection||!n)return;t>i.infection.stages.length||t<0||void 0!==n.stage&&n.stage>t||(n.stage=t,n.time=0)}}class a{constructor(e){this._container=e,this._container.infecter=new s(this._container)}particleFillColor(e){const t=this._container.actualOptions;if(!e.infection||!t.infection)return;const i=e.infection.stage,n=t.infection.stages;return void 0!==i?n[i].color:void 0}particleStrokeColor(e){return this.particleFillColor(e)}particlesSetup(){const t=this._container.actualOptions;if(t.infection)for(let i=0;i<t.infection.infections;i++){const t=this._container.particles.filter((e=>{const t=e;return t.infection||(t.infection={}),void 0===t.infection.stage})),i=(0,e.itemFromArray)(t);this._container.infecter?.startInfection(i,0)}}}class r extends e.ParticlesInteractorBase{constructor(e){super(e)}clear(){}init(){}async interact(t,i){const n=this.container.infecter;if(!n)return;if(n.updateInfection(t,i.value),void 0===t.infection?.stage)return;const o=this.container,s=o.actualOptions.infection;if(!s?.enable||s.stages.length<1)return;const a=s.stages[t.infection.stage],r=o.retina.pixelRatio,c=2*t.getRadius()+a.radius*r,l=t.getPosition(),d=a.infectedStage??t.infection.stage,f=o.particles.quadTree.queryCircle(l,c),u=a.rate,g=f.length;for(const i of f){const o=i;if(!(o===t||o.destroyed||o.spawning||void 0!==o.infection?.stage&&o.infection.stage===t.infection.stage||(0,e.getRandom)()>=u/g))if(void 0===o.infection?.stage)n.startInfection(o,d);else if(o.infection.stage<t.infection.stage)n.updateInfectionStage(o,d);else if(o.infection.stage>t.infection.stage){const e=s.stages[o.infection.stage],i=e?.infectedStage??o.infection.stage;n.updateInfectionStage(t,i)}}await Promise.resolve()}isEnabled(){return this.container.actualOptions?.infection?.enable??!1}reset(){}}class c{constructor(){this.id="infection"}getPlugin(e){return new a(e)}loadOptions(e,t){if(!this.needsPlugin(e)&&!this.needsPlugin(t))return;let n=e.infection;void 0===n?.load&&(e.infection=n=new i),n.load(t?.infection)}needsPlugin(e){return e?.infection?.enable??!1}}async function l(e,t=!0){const i=new c;await e.addPlugin(i,t),await e.addInteractor("particlesInfection",(e=>new r(e)),t)}})(),o})()));
@@ -1 +1 @@
1
- /*! tsParticles Infection Plugin v3.0.3 by Matteo Bruni */
1
+ /*! tsParticles Infection Plugin v3.1.0 by Matteo Bruni */
package/umd/Infecter.js CHANGED
@@ -4,12 +4,14 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
7
+ define(["require", "exports", "@tsparticles/engine"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Infecter = void 0;
13
+ const engine_1 = require("@tsparticles/engine");
14
+ const minStage = 0, minDuration = 0;
13
15
  class Infecter {
14
16
  constructor(container) {
15
17
  this._nextInfectionStage = (particle) => {
@@ -18,7 +20,7 @@
18
20
  return;
19
21
  }
20
22
  const stagesCount = infectionOptions.stages.length;
21
- if (stagesCount <= 0 || infection.stage === undefined) {
23
+ if (stagesCount <= minStage || infection.stage === undefined) {
22
24
  return;
23
25
  }
24
26
  infection.time = 0;
@@ -26,7 +28,6 @@
26
28
  if (infectionOptions.cure) {
27
29
  delete infection.stage;
28
30
  delete infection.time;
29
- return;
30
31
  }
31
32
  else {
32
33
  infection.stage = 0;
@@ -42,7 +43,7 @@
42
43
  return;
43
44
  }
44
45
  const stages = infectionOptions.stages, stagesCount = stages.length;
45
- if (stage > stagesCount || stage < 0) {
46
+ if (stage > stagesCount || stage < minStage) {
46
47
  return;
47
48
  }
48
49
  infection.delay = 0;
@@ -56,10 +57,10 @@
56
57
  const stages = infectionOptions.stages, stagesCount = stages.length;
57
58
  if (infection.delay !== undefined && infection.delayStage !== undefined) {
58
59
  const stage = infection.delayStage;
59
- if (stage > stagesCount || stage < 0) {
60
+ if (stage > stagesCount || stage < minStage) {
60
61
  return;
61
62
  }
62
- if (infection.delay >= infectionOptions.delay * 1000) {
63
+ if (infection.delay >= infectionOptions.delay * engine_1.millisecondsToSeconds) {
63
64
  infection.stage = stage;
64
65
  infection.time = 0;
65
66
  delete infection.delay;
@@ -75,8 +76,8 @@
75
76
  }
76
77
  if (infection.stage !== undefined && infection.time !== undefined) {
77
78
  const infectionStage = stages[infection.stage];
78
- if (infectionStage.duration !== undefined && infectionStage.duration >= 0) {
79
- if (infection.time > infectionStage.duration * 1000) {
79
+ if (infectionStage.duration !== undefined && infectionStage.duration >= minDuration) {
80
+ if (infection.time > infectionStage.duration * engine_1.millisecondsToSeconds) {
80
81
  this._nextInfectionStage(particle);
81
82
  }
82
83
  else {
@@ -98,7 +99,7 @@
98
99
  return;
99
100
  }
100
101
  const stagesCount = options.infection.stages.length;
101
- if (stage > stagesCount || stage < 0 || (infection.stage !== undefined && infection.stage > stage)) {
102
+ if (stage > stagesCount || stage < minStage || (infection.stage !== undefined && infection.stage > stage)) {
102
103
  return;
103
104
  }
104
105
  infection.stage = stage;
@@ -12,6 +12,7 @@
12
12
  exports.InfectionInstance = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  const Infecter_js_1 = require("./Infecter.js");
15
+ const minStage = 0;
15
16
  class InfectionInstance {
16
17
  constructor(container) {
17
18
  this._container = container;
@@ -42,7 +43,7 @@
42
43
  return infP.infection.stage === undefined;
43
44
  });
44
45
  const infected = (0, engine_1.itemFromArray)(notInfected);
45
- this._container.infecter?.startInfection(infected, 0);
46
+ this._container.infecter?.startInfection(infected, minStage);
46
47
  }
47
48
  }
48
49
  }
@@ -11,6 +11,7 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ParticlesInfecter = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
+ const minStagesCount = 1, double = 2;
14
15
  class ParticlesInfecter extends engine_1.ParticlesInteractorBase {
15
16
  constructor(container) {
16
17
  super(container);
@@ -29,10 +30,10 @@
29
30
  return;
30
31
  }
31
32
  const container = this.container, options = container.actualOptions, infectionOptions = options.infection;
32
- if (!infectionOptions?.enable || infectionOptions.stages.length < 1) {
33
+ if (!infectionOptions?.enable || infectionOptions.stages.length < minStagesCount) {
33
34
  return;
34
35
  }
35
- const infectionStage1 = infectionOptions.stages[p1.infection.stage], pxRatio = container.retina.pixelRatio, radius = p1.getRadius() * 2 + infectionStage1.radius * pxRatio, pos = p1.getPosition(), infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage, query = container.particles.quadTree.queryCircle(pos, radius), infections = infectionStage1.rate, neighbors = query.length;
36
+ const infectionStage1 = infectionOptions.stages[p1.infection.stage], pxRatio = container.retina.pixelRatio, radius = p1.getRadius() * double + infectionStage1.radius * pxRatio, pos = p1.getPosition(), infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage, query = container.particles.quadTree.queryCircle(pos, radius), infections = infectionStage1.rate, neighbors = query.length;
36
37
  for (const p2 of query) {
37
38
  const infP2 = p2;
38
39
  if (infP2 === p1 ||
@@ -54,6 +55,7 @@
54
55
  infecter.updateInfectionStage(p1, infectedStage2);
55
56
  }
56
57
  }
58
+ await Promise.resolve();
57
59
  }
58
60
  isEnabled() {
59
61
  return this.container.actualOptions?.infection?.enable ?? false;