@tsparticles/updater-out-modes 3.2.2 → 3.4.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.
Files changed (57) hide show
  1. package/browser/BounceOutMode.js +7 -6
  2. package/browser/DestroyOutMode.js +6 -7
  3. package/browser/NoneOutMode.js +7 -8
  4. package/browser/OutOfCanvasUpdater.js +17 -16
  5. package/browser/OutOutMode.js +10 -11
  6. package/browser/Utils.js +19 -19
  7. package/browser/index.js +3 -3
  8. package/cjs/BounceOutMode.js +8 -30
  9. package/cjs/DestroyOutMode.js +5 -6
  10. package/cjs/NoneOutMode.js +6 -7
  11. package/cjs/OutOfCanvasUpdater.js +21 -43
  12. package/cjs/OutOutMode.js +9 -10
  13. package/cjs/Utils.js +18 -18
  14. package/cjs/index.js +3 -26
  15. package/esm/BounceOutMode.js +7 -6
  16. package/esm/DestroyOutMode.js +6 -7
  17. package/esm/NoneOutMode.js +7 -8
  18. package/esm/OutOfCanvasUpdater.js +17 -16
  19. package/esm/OutOutMode.js +10 -11
  20. package/esm/Utils.js +19 -19
  21. package/esm/index.js +3 -3
  22. package/package.json +2 -2
  23. package/report.html +1 -1
  24. package/tsparticles.updater.out-modes.js +62 -200
  25. package/tsparticles.updater.out-modes.min.js +1 -1
  26. package/tsparticles.updater.out-modes.min.js.LICENSE.txt +1 -1
  27. package/types/BounceOutMode.d.ts +1 -1
  28. package/types/DestroyOutMode.d.ts +1 -1
  29. package/types/IOutModeManager.d.ts +1 -1
  30. package/types/NoneOutMode.d.ts +1 -1
  31. package/types/OutOfCanvasUpdater.d.ts +2 -2
  32. package/types/OutOutMode.d.ts +1 -1
  33. package/umd/BounceOutMode.js +9 -32
  34. package/umd/DestroyOutMode.js +5 -6
  35. package/umd/NoneOutMode.js +6 -7
  36. package/umd/OutOfCanvasUpdater.js +22 -45
  37. package/umd/OutOutMode.js +9 -10
  38. package/umd/Utils.js +18 -18
  39. package/umd/index.js +4 -28
  40. package/103.min.js +0 -2
  41. package/103.min.js.LICENSE.txt +0 -1
  42. package/388.min.js +0 -2
  43. package/388.min.js.LICENSE.txt +0 -1
  44. package/53.min.js +0 -2
  45. package/53.min.js.LICENSE.txt +0 -1
  46. package/569.min.js +0 -2
  47. package/569.min.js.LICENSE.txt +0 -1
  48. package/886.min.js +0 -2
  49. package/886.min.js.LICENSE.txt +0 -1
  50. package/920.min.js +0 -2
  51. package/920.min.js.LICENSE.txt +0 -1
  52. package/dist_browser_BounceOutMode_js.js +0 -30
  53. package/dist_browser_DestroyOutMode_js.js +0 -30
  54. package/dist_browser_NoneOutMode_js.js +0 -30
  55. package/dist_browser_OutOfCanvasUpdater_js.js +0 -30
  56. package/dist_browser_OutOutMode_js.js +0 -30
  57. package/dist_browser_Utils_js.js +0 -30
@@ -1,13 +1,14 @@
1
- import { calculateBounds, } from "@tsparticles/engine";
1
+ import { OutMode, calculateBounds, } from "@tsparticles/engine";
2
+ import { bounceHorizontal, bounceVertical } from "./Utils.js";
2
3
  export class BounceOutMode {
3
4
  constructor(container) {
4
5
  this.container = container;
5
6
  this.modes = [
6
- "bounce",
7
- "split",
7
+ OutMode.bounce,
8
+ OutMode.split,
8
9
  ];
9
10
  }
10
- async update(particle, direction, delta, outMode) {
11
+ update(particle, direction, delta, outMode) {
11
12
  if (!this.modes.includes(outMode)) {
12
13
  return;
13
14
  }
@@ -15,7 +16,7 @@ export class BounceOutMode {
15
16
  let handled = false;
16
17
  for (const [, plugin] of container.plugins) {
17
18
  if (plugin.particleBounce !== undefined) {
18
- handled = await plugin.particleBounce(particle, delta, direction);
19
+ handled = plugin.particleBounce(particle, delta, direction);
19
20
  }
20
21
  if (handled) {
21
22
  break;
@@ -24,7 +25,7 @@ export class BounceOutMode {
24
25
  if (handled) {
25
26
  return;
26
27
  }
27
- const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size, { bounceHorizontal, bounceVertical } = await import("./Utils.js");
28
+ const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size;
28
29
  bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, size });
29
30
  bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, size });
30
31
  }
@@ -1,23 +1,23 @@
1
- import { Vector, getDistances, isPointInside, } from "@tsparticles/engine";
1
+ import { OutMode, ParticleOutType, Vector, getDistances, isPointInside, } from "@tsparticles/engine";
2
2
  const minVelocity = 0;
3
3
  export class DestroyOutMode {
4
4
  constructor(container) {
5
5
  this.container = container;
6
- this.modes = ["destroy"];
6
+ this.modes = [OutMode.destroy];
7
7
  }
8
- async update(particle, direction, _delta, outMode) {
8
+ update(particle, direction, _delta, outMode) {
9
9
  if (!this.modes.includes(outMode)) {
10
10
  return;
11
11
  }
12
12
  const container = this.container;
13
13
  switch (particle.outType) {
14
- case "normal":
15
- case "outside":
14
+ case ParticleOutType.normal:
15
+ case ParticleOutType.outside:
16
16
  if (isPointInside(particle.position, container.canvas.size, Vector.origin, particle.getRadius(), direction)) {
17
17
  return;
18
18
  }
19
19
  break;
20
- case "inside": {
20
+ case ParticleOutType.inside: {
21
21
  const { dx, dy } = getDistances(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity;
22
22
  if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
23
23
  (vy < minVelocity && dy > particle.moveCenter.radius) ||
@@ -29,6 +29,5 @@ export class DestroyOutMode {
29
29
  }
30
30
  }
31
31
  container.particles.remove(particle, undefined, true);
32
- await Promise.resolve();
33
32
  }
34
33
  }
@@ -1,18 +1,18 @@
1
- import { Vector, isPointInside, } from "@tsparticles/engine";
1
+ import { OutMode, OutModeDirection, Vector, isPointInside, } from "@tsparticles/engine";
2
2
  const minVelocity = 0;
3
3
  export class NoneOutMode {
4
4
  constructor(container) {
5
5
  this.container = container;
6
- this.modes = ["none"];
6
+ this.modes = [OutMode.none];
7
7
  }
8
- async update(particle, direction, delta, outMode) {
8
+ update(particle, direction, delta, outMode) {
9
9
  if (!this.modes.includes(outMode)) {
10
10
  return;
11
11
  }
12
12
  if ((particle.options.move.distance.horizontal &&
13
- (direction === "left" || direction === "right")) ??
13
+ (direction === OutModeDirection.left || direction === OutModeDirection.right)) ??
14
14
  (particle.options.move.distance.vertical &&
15
- (direction === "top" || direction === "bottom"))) {
15
+ (direction === OutModeDirection.top || direction === OutModeDirection.bottom))) {
16
16
  return;
17
17
  }
18
18
  const gravityOptions = particle.options.move.gravity, container = this.container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
@@ -31,11 +31,10 @@ export class NoneOutMode {
31
31
  const position = particle.position;
32
32
  if ((!gravityOptions.inverse &&
33
33
  position.y > canvasSize.height + pRadius &&
34
- direction === "bottom") ||
35
- (gravityOptions.inverse && position.y < -pRadius && direction === "top")) {
34
+ direction === OutModeDirection.bottom) ||
35
+ (gravityOptions.inverse && position.y < -pRadius && direction === OutModeDirection.top)) {
36
36
  container.particles.remove(particle);
37
37
  }
38
38
  }
39
- await Promise.resolve();
40
39
  }
41
40
  }
@@ -1,3 +1,8 @@
1
+ import { OutMode, OutModeDirection, } from "@tsparticles/engine";
2
+ import { BounceOutMode } from "./BounceOutMode.js";
3
+ import { DestroyOutMode } from "./DestroyOutMode.js";
4
+ import { NoneOutMode } from "./NoneOutMode.js";
5
+ import { OutOutMode } from "./OutOutMode.js";
1
6
  const checkOutMode = (outModes, outMode) => {
2
7
  return (outModes.default === outMode ||
3
8
  outModes.bottom === outMode ||
@@ -7,42 +12,38 @@ const checkOutMode = (outModes, outMode) => {
7
12
  };
8
13
  export class OutOfCanvasUpdater {
9
14
  constructor(container) {
10
- this._updateOutMode = async (particle, delta, outMode, direction) => {
15
+ this._updateOutMode = (particle, delta, outMode, direction) => {
11
16
  for (const updater of this.updaters) {
12
- await updater.update(particle, direction, delta, outMode);
17
+ updater.update(particle, direction, delta, outMode);
13
18
  }
14
19
  };
15
20
  this.container = container;
16
21
  this.updaters = [];
17
22
  }
18
- async init(particle) {
23
+ init(particle) {
19
24
  this.updaters = [];
20
25
  const outModes = particle.options.move.outModes;
21
- if (checkOutMode(outModes, "bounce")) {
22
- const { BounceOutMode } = await import("./BounceOutMode.js");
26
+ if (checkOutMode(outModes, OutMode.bounce)) {
23
27
  this.updaters.push(new BounceOutMode(this.container));
24
28
  }
25
- else if (checkOutMode(outModes, "out")) {
26
- const { OutOutMode } = await import("./OutOutMode.js");
29
+ else if (checkOutMode(outModes, OutMode.out)) {
27
30
  this.updaters.push(new OutOutMode(this.container));
28
31
  }
29
- else if (checkOutMode(outModes, "destroy")) {
30
- const { DestroyOutMode } = await import("./DestroyOutMode.js");
32
+ else if (checkOutMode(outModes, OutMode.destroy)) {
31
33
  this.updaters.push(new DestroyOutMode(this.container));
32
34
  }
33
- else if (checkOutMode(outModes, "none")) {
34
- const { NoneOutMode } = await import("./NoneOutMode.js");
35
+ else if (checkOutMode(outModes, OutMode.none)) {
35
36
  this.updaters.push(new NoneOutMode(this.container));
36
37
  }
37
38
  }
38
39
  isEnabled(particle) {
39
40
  return !particle.destroyed && !particle.spawning;
40
41
  }
41
- async update(particle, delta) {
42
+ update(particle, delta) {
42
43
  const outModes = particle.options.move.outModes;
43
- await this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom");
44
- await this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left");
45
- await this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right");
46
- await this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top");
44
+ this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, OutModeDirection.bottom);
45
+ this._updateOutMode(particle, delta, outModes.left ?? outModes.default, OutModeDirection.left);
46
+ this._updateOutMode(particle, delta, outModes.right ?? outModes.default, OutModeDirection.right);
47
+ this._updateOutMode(particle, delta, outModes.top ?? outModes.default, OutModeDirection.top);
47
48
  }
48
49
  }
@@ -1,17 +1,17 @@
1
- import { Vector, calculateBounds, getDistances, getRandom, isPointInside, randomInRange, } from "@tsparticles/engine";
1
+ import { OutMode, OutModeDirection, ParticleOutType, Vector, calculateBounds, getDistances, getRandom, isPointInside, randomInRange, } from "@tsparticles/engine";
2
2
  const minVelocity = 0, minDistance = 0;
3
3
  export class OutOutMode {
4
4
  constructor(container) {
5
5
  this.container = container;
6
- this.modes = ["out"];
6
+ this.modes = [OutMode.out];
7
7
  }
8
- async update(particle, direction, delta, outMode) {
8
+ update(particle, direction, delta, outMode) {
9
9
  if (!this.modes.includes(outMode)) {
10
10
  return;
11
11
  }
12
12
  const container = this.container;
13
13
  switch (particle.outType) {
14
- case "inside": {
14
+ case ParticleOutType.inside: {
15
15
  const { x: vx, y: vy } = particle.velocity;
16
16
  const circVec = Vector.origin;
17
17
  circVec.length = particle.moveCenter.radius;
@@ -42,7 +42,7 @@ export class OutOutMode {
42
42
  return;
43
43
  }
44
44
  switch (particle.outType) {
45
- case "outside": {
45
+ case ParticleOutType.outside: {
46
46
  particle.position.x =
47
47
  Math.floor(randomInRange({
48
48
  min: -particle.moveCenter.radius,
@@ -60,14 +60,14 @@ export class OutOutMode {
60
60
  }
61
61
  break;
62
62
  }
63
- case "normal": {
63
+ case ParticleOutType.normal: {
64
64
  const warp = particle.options.move.warp, canvasSize = container.canvas.size, newPos = {
65
65
  bottom: canvasSize.height + particle.getRadius() + particle.offset.y,
66
66
  left: -particle.getRadius() - particle.offset.x,
67
67
  right: canvasSize.width + particle.getRadius() + particle.offset.x,
68
68
  top: -particle.getRadius() - particle.offset.y,
69
69
  }, sizeValue = particle.getRadius(), nextBounds = calculateBounds(particle.position, sizeValue);
70
- if (direction === "right" &&
70
+ if (direction === OutModeDirection.right &&
71
71
  nextBounds.left > canvasSize.width + particle.offset.x) {
72
72
  particle.position.x = newPos.left;
73
73
  particle.initialPosition.x = particle.position.x;
@@ -76,7 +76,7 @@ export class OutOutMode {
76
76
  particle.initialPosition.y = particle.position.y;
77
77
  }
78
78
  }
79
- else if (direction === "left" && nextBounds.right < -particle.offset.x) {
79
+ else if (direction === OutModeDirection.left && nextBounds.right < -particle.offset.x) {
80
80
  particle.position.x = newPos.right;
81
81
  particle.initialPosition.x = particle.position.x;
82
82
  if (!warp) {
@@ -84,7 +84,7 @@ export class OutOutMode {
84
84
  particle.initialPosition.y = particle.position.y;
85
85
  }
86
86
  }
87
- if (direction === "bottom" &&
87
+ if (direction === OutModeDirection.bottom &&
88
88
  nextBounds.top > canvasSize.height + particle.offset.y) {
89
89
  if (!warp) {
90
90
  particle.position.x = getRandom() * canvasSize.width;
@@ -93,7 +93,7 @@ export class OutOutMode {
93
93
  particle.position.y = newPos.top;
94
94
  particle.initialPosition.y = particle.position.y;
95
95
  }
96
- else if (direction === "top" && nextBounds.bottom < -particle.offset.y) {
96
+ else if (direction === OutModeDirection.top && nextBounds.bottom < -particle.offset.y) {
97
97
  if (!warp) {
98
98
  particle.position.x = getRandom() * canvasSize.width;
99
99
  particle.initialPosition.x = particle.position.x;
@@ -107,6 +107,5 @@ export class OutOutMode {
107
107
  break;
108
108
  }
109
109
  }
110
- await Promise.resolve();
111
110
  }
112
111
  }
package/browser/Utils.js CHANGED
@@ -1,22 +1,22 @@
1
- import { getRangeValue } from "@tsparticles/engine";
1
+ import { OutMode, OutModeDirection, getRangeValue } from "@tsparticles/engine";
2
2
  const minVelocity = 0, boundsMin = 0;
3
3
  export function bounceHorizontal(data) {
4
- if ((data.outMode !== "bounce" && data.outMode !== "split") ||
5
- (data.direction !== "left" && data.direction !== "right")) {
4
+ if ((data.outMode !== OutMode.bounce && data.outMode !== OutMode.split) ||
5
+ (data.direction !== OutModeDirection.left && data.direction !== OutModeDirection.right)) {
6
6
  return;
7
7
  }
8
- if (data.bounds.right < boundsMin && data.direction === "left") {
8
+ if (data.bounds.right < boundsMin && data.direction === OutModeDirection.left) {
9
9
  data.particle.position.x = data.size + data.offset.x;
10
10
  }
11
- else if (data.bounds.left > data.canvasSize.width && data.direction === "right") {
11
+ else if (data.bounds.left > data.canvasSize.width && data.direction === OutModeDirection.right) {
12
12
  data.particle.position.x = data.canvasSize.width - data.size - data.offset.x;
13
13
  }
14
14
  const velocity = data.particle.velocity.x;
15
15
  let bounced = false;
16
- if ((data.direction === "right" &&
16
+ if ((data.direction === OutModeDirection.right &&
17
17
  data.bounds.right >= data.canvasSize.width &&
18
18
  velocity > minVelocity) ||
19
- (data.direction === "left" && data.bounds.left <= boundsMin && velocity < minVelocity)) {
19
+ (data.direction === OutModeDirection.left && data.bounds.left <= boundsMin && velocity < minVelocity)) {
20
20
  const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);
21
21
  data.particle.velocity.x *= -newVelocity;
22
22
  bounced = true;
@@ -25,33 +25,33 @@ export function bounceHorizontal(data) {
25
25
  return;
26
26
  }
27
27
  const minPos = data.offset.x + data.size;
28
- if (data.bounds.right >= data.canvasSize.width && data.direction === "right") {
28
+ if (data.bounds.right >= data.canvasSize.width && data.direction === OutModeDirection.right) {
29
29
  data.particle.position.x = data.canvasSize.width - minPos;
30
30
  }
31
- else if (data.bounds.left <= boundsMin && data.direction === "left") {
31
+ else if (data.bounds.left <= boundsMin && data.direction === OutModeDirection.left) {
32
32
  data.particle.position.x = minPos;
33
33
  }
34
- if (data.outMode === "split") {
34
+ if (data.outMode === OutMode.split) {
35
35
  data.particle.destroy();
36
36
  }
37
37
  }
38
38
  export function bounceVertical(data) {
39
- if ((data.outMode !== "bounce" && data.outMode !== "split") ||
40
- (data.direction !== "bottom" && data.direction !== "top")) {
39
+ if ((data.outMode !== OutMode.bounce && data.outMode !== OutMode.split) ||
40
+ (data.direction !== OutModeDirection.bottom && data.direction !== OutModeDirection.top)) {
41
41
  return;
42
42
  }
43
- if (data.bounds.bottom < boundsMin && data.direction === "top") {
43
+ if (data.bounds.bottom < boundsMin && data.direction === OutModeDirection.top) {
44
44
  data.particle.position.y = data.size + data.offset.y;
45
45
  }
46
- else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") {
46
+ else if (data.bounds.top > data.canvasSize.height && data.direction === OutModeDirection.bottom) {
47
47
  data.particle.position.y = data.canvasSize.height - data.size - data.offset.y;
48
48
  }
49
49
  const velocity = data.particle.velocity.y;
50
50
  let bounced = false;
51
- if ((data.direction === "bottom" &&
51
+ if ((data.direction === OutModeDirection.bottom &&
52
52
  data.bounds.bottom >= data.canvasSize.height &&
53
53
  velocity > minVelocity) ||
54
- (data.direction === "top" && data.bounds.top <= boundsMin && velocity < minVelocity)) {
54
+ (data.direction === OutModeDirection.top && data.bounds.top <= boundsMin && velocity < minVelocity)) {
55
55
  const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);
56
56
  data.particle.velocity.y *= -newVelocity;
57
57
  bounced = true;
@@ -60,13 +60,13 @@ export function bounceVertical(data) {
60
60
  return;
61
61
  }
62
62
  const minPos = data.offset.y + data.size;
63
- if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") {
63
+ if (data.bounds.bottom >= data.canvasSize.height && data.direction === OutModeDirection.bottom) {
64
64
  data.particle.position.y = data.canvasSize.height - minPos;
65
65
  }
66
- else if (data.bounds.top <= boundsMin && data.direction === "top") {
66
+ else if (data.bounds.top <= boundsMin && data.direction === OutModeDirection.top) {
67
67
  data.particle.position.y = minPos;
68
68
  }
69
- if (data.outMode === "split") {
69
+ if (data.outMode === OutMode.split) {
70
70
  data.particle.destroy();
71
71
  }
72
72
  }
package/browser/index.js CHANGED
@@ -1,6 +1,6 @@
1
+ import { OutOfCanvasUpdater } from "./OutOfCanvasUpdater.js";
1
2
  export async function loadOutModesUpdater(engine, refresh = true) {
2
- await engine.addParticleUpdater("outModes", async (container) => {
3
- const { OutOfCanvasUpdater } = await import("./OutOfCanvasUpdater.js");
4
- return new OutOfCanvasUpdater(container);
3
+ await engine.addParticleUpdater("outModes", container => {
4
+ return Promise.resolve(new OutOfCanvasUpdater(container));
5
5
  }, refresh);
6
6
  }
@@ -1,39 +1,17 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.BounceOutMode = void 0;
27
4
  const engine_1 = require("@tsparticles/engine");
5
+ const Utils_js_1 = require("./Utils.js");
28
6
  class BounceOutMode {
29
7
  constructor(container) {
30
8
  this.container = container;
31
9
  this.modes = [
32
- "bounce",
33
- "split",
10
+ engine_1.OutMode.bounce,
11
+ engine_1.OutMode.split,
34
12
  ];
35
13
  }
36
- async update(particle, direction, delta, outMode) {
14
+ update(particle, direction, delta, outMode) {
37
15
  if (!this.modes.includes(outMode)) {
38
16
  return;
39
17
  }
@@ -41,7 +19,7 @@ class BounceOutMode {
41
19
  let handled = false;
42
20
  for (const [, plugin] of container.plugins) {
43
21
  if (plugin.particleBounce !== undefined) {
44
- handled = await plugin.particleBounce(particle, delta, direction);
22
+ handled = plugin.particleBounce(particle, delta, direction);
45
23
  }
46
24
  if (handled) {
47
25
  break;
@@ -50,9 +28,9 @@ class BounceOutMode {
50
28
  if (handled) {
51
29
  return;
52
30
  }
53
- const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = (0, engine_1.calculateBounds)(pos, size), canvasSize = container.canvas.size, { bounceHorizontal, bounceVertical } = await Promise.resolve().then(() => __importStar(require("./Utils.js")));
54
- bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, size });
55
- bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, size });
31
+ const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = (0, engine_1.calculateBounds)(pos, size), canvasSize = container.canvas.size;
32
+ (0, Utils_js_1.bounceHorizontal)({ particle, outMode, direction, bounds, canvasSize, offset, size });
33
+ (0, Utils_js_1.bounceVertical)({ particle, outMode, direction, bounds, canvasSize, offset, size });
56
34
  }
57
35
  }
58
36
  exports.BounceOutMode = BounceOutMode;
@@ -6,21 +6,21 @@ const minVelocity = 0;
6
6
  class DestroyOutMode {
7
7
  constructor(container) {
8
8
  this.container = container;
9
- this.modes = ["destroy"];
9
+ this.modes = [engine_1.OutMode.destroy];
10
10
  }
11
- async update(particle, direction, _delta, outMode) {
11
+ update(particle, direction, _delta, outMode) {
12
12
  if (!this.modes.includes(outMode)) {
13
13
  return;
14
14
  }
15
15
  const container = this.container;
16
16
  switch (particle.outType) {
17
- case "normal":
18
- case "outside":
17
+ case engine_1.ParticleOutType.normal:
18
+ case engine_1.ParticleOutType.outside:
19
19
  if ((0, engine_1.isPointInside)(particle.position, container.canvas.size, engine_1.Vector.origin, particle.getRadius(), direction)) {
20
20
  return;
21
21
  }
22
22
  break;
23
- case "inside": {
23
+ case engine_1.ParticleOutType.inside: {
24
24
  const { dx, dy } = (0, engine_1.getDistances)(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity;
25
25
  if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
26
26
  (vy < minVelocity && dy > particle.moveCenter.radius) ||
@@ -32,7 +32,6 @@ class DestroyOutMode {
32
32
  }
33
33
  }
34
34
  container.particles.remove(particle, undefined, true);
35
- await Promise.resolve();
36
35
  }
37
36
  }
38
37
  exports.DestroyOutMode = DestroyOutMode;
@@ -6,16 +6,16 @@ const minVelocity = 0;
6
6
  class NoneOutMode {
7
7
  constructor(container) {
8
8
  this.container = container;
9
- this.modes = ["none"];
9
+ this.modes = [engine_1.OutMode.none];
10
10
  }
11
- async update(particle, direction, delta, outMode) {
11
+ update(particle, direction, delta, outMode) {
12
12
  if (!this.modes.includes(outMode)) {
13
13
  return;
14
14
  }
15
15
  if ((particle.options.move.distance.horizontal &&
16
- (direction === "left" || direction === "right")) ??
16
+ (direction === engine_1.OutModeDirection.left || direction === engine_1.OutModeDirection.right)) ??
17
17
  (particle.options.move.distance.vertical &&
18
- (direction === "top" || direction === "bottom"))) {
18
+ (direction === engine_1.OutModeDirection.top || direction === engine_1.OutModeDirection.bottom))) {
19
19
  return;
20
20
  }
21
21
  const gravityOptions = particle.options.move.gravity, container = this.container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
@@ -34,12 +34,11 @@ class NoneOutMode {
34
34
  const position = particle.position;
35
35
  if ((!gravityOptions.inverse &&
36
36
  position.y > canvasSize.height + pRadius &&
37
- direction === "bottom") ||
38
- (gravityOptions.inverse && position.y < -pRadius && direction === "top")) {
37
+ direction === engine_1.OutModeDirection.bottom) ||
38
+ (gravityOptions.inverse && position.y < -pRadius && direction === engine_1.OutModeDirection.top)) {
39
39
  container.particles.remove(particle);
40
40
  }
41
41
  }
42
- await Promise.resolve();
43
42
  }
44
43
  }
45
44
  exports.NoneOutMode = NoneOutMode;
@@ -1,29 +1,11 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.OutOfCanvasUpdater = void 0;
4
+ const engine_1 = require("@tsparticles/engine");
5
+ const BounceOutMode_js_1 = require("./BounceOutMode.js");
6
+ const DestroyOutMode_js_1 = require("./DestroyOutMode.js");
7
+ const NoneOutMode_js_1 = require("./NoneOutMode.js");
8
+ const OutOutMode_js_1 = require("./OutOutMode.js");
27
9
  const checkOutMode = (outModes, outMode) => {
28
10
  return (outModes.default === outMode ||
29
11
  outModes.bottom === outMode ||
@@ -33,43 +15,39 @@ const checkOutMode = (outModes, outMode) => {
33
15
  };
34
16
  class OutOfCanvasUpdater {
35
17
  constructor(container) {
36
- this._updateOutMode = async (particle, delta, outMode, direction) => {
18
+ this._updateOutMode = (particle, delta, outMode, direction) => {
37
19
  for (const updater of this.updaters) {
38
- await updater.update(particle, direction, delta, outMode);
20
+ updater.update(particle, direction, delta, outMode);
39
21
  }
40
22
  };
41
23
  this.container = container;
42
24
  this.updaters = [];
43
25
  }
44
- async init(particle) {
26
+ init(particle) {
45
27
  this.updaters = [];
46
28
  const outModes = particle.options.move.outModes;
47
- if (checkOutMode(outModes, "bounce")) {
48
- const { BounceOutMode } = await Promise.resolve().then(() => __importStar(require("./BounceOutMode.js")));
49
- this.updaters.push(new BounceOutMode(this.container));
29
+ if (checkOutMode(outModes, engine_1.OutMode.bounce)) {
30
+ this.updaters.push(new BounceOutMode_js_1.BounceOutMode(this.container));
50
31
  }
51
- else if (checkOutMode(outModes, "out")) {
52
- const { OutOutMode } = await Promise.resolve().then(() => __importStar(require("./OutOutMode.js")));
53
- this.updaters.push(new OutOutMode(this.container));
32
+ else if (checkOutMode(outModes, engine_1.OutMode.out)) {
33
+ this.updaters.push(new OutOutMode_js_1.OutOutMode(this.container));
54
34
  }
55
- else if (checkOutMode(outModes, "destroy")) {
56
- const { DestroyOutMode } = await Promise.resolve().then(() => __importStar(require("./DestroyOutMode.js")));
57
- this.updaters.push(new DestroyOutMode(this.container));
35
+ else if (checkOutMode(outModes, engine_1.OutMode.destroy)) {
36
+ this.updaters.push(new DestroyOutMode_js_1.DestroyOutMode(this.container));
58
37
  }
59
- else if (checkOutMode(outModes, "none")) {
60
- const { NoneOutMode } = await Promise.resolve().then(() => __importStar(require("./NoneOutMode.js")));
61
- this.updaters.push(new NoneOutMode(this.container));
38
+ else if (checkOutMode(outModes, engine_1.OutMode.none)) {
39
+ this.updaters.push(new NoneOutMode_js_1.NoneOutMode(this.container));
62
40
  }
63
41
  }
64
42
  isEnabled(particle) {
65
43
  return !particle.destroyed && !particle.spawning;
66
44
  }
67
- async update(particle, delta) {
45
+ update(particle, delta) {
68
46
  const outModes = particle.options.move.outModes;
69
- await this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom");
70
- await this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left");
71
- await this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right");
72
- await this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top");
47
+ this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, engine_1.OutModeDirection.bottom);
48
+ this._updateOutMode(particle, delta, outModes.left ?? outModes.default, engine_1.OutModeDirection.left);
49
+ this._updateOutMode(particle, delta, outModes.right ?? outModes.default, engine_1.OutModeDirection.right);
50
+ this._updateOutMode(particle, delta, outModes.top ?? outModes.default, engine_1.OutModeDirection.top);
73
51
  }
74
52
  }
75
53
  exports.OutOfCanvasUpdater = OutOfCanvasUpdater;