@tsparticles/updater-out-modes 3.2.1 → 3.3.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 (52) hide show
  1. package/128.min.js +2 -0
  2. package/128.min.js.LICENSE.txt +1 -0
  3. package/browser/BounceOutMode.js +4 -3
  4. package/browser/DestroyOutMode.js +1 -2
  5. package/browser/NoneOutMode.js +1 -2
  6. package/browser/OutOfCanvasUpdater.js +12 -12
  7. package/browser/OutOutMode.js +1 -2
  8. package/cjs/BounceOutMode.js +6 -28
  9. package/cjs/DestroyOutMode.js +1 -2
  10. package/cjs/NoneOutMode.js +1 -2
  11. package/cjs/OutOfCanvasUpdater.js +16 -39
  12. package/cjs/OutOutMode.js +1 -2
  13. package/cjs/index.js +1 -24
  14. package/dist_browser_OutOfCanvasUpdater_js.js +52 -2
  15. package/esm/BounceOutMode.js +4 -3
  16. package/esm/DestroyOutMode.js +1 -2
  17. package/esm/NoneOutMode.js +1 -2
  18. package/esm/OutOfCanvasUpdater.js +12 -12
  19. package/esm/OutOutMode.js +1 -2
  20. package/package.json +2 -2
  21. package/report.html +1 -1
  22. package/tsparticles.updater.out-modes.js +2 -2
  23. package/tsparticles.updater.out-modes.min.js +1 -1
  24. package/tsparticles.updater.out-modes.min.js.LICENSE.txt +1 -1
  25. package/types/BounceOutMode.d.ts +1 -1
  26. package/types/DestroyOutMode.d.ts +1 -1
  27. package/types/IOutModeManager.d.ts +1 -1
  28. package/types/NoneOutMode.d.ts +1 -1
  29. package/types/OutOfCanvasUpdater.d.ts +2 -2
  30. package/types/OutOutMode.d.ts +1 -1
  31. package/umd/BounceOutMode.js +7 -30
  32. package/umd/DestroyOutMode.js +1 -2
  33. package/umd/NoneOutMode.js +1 -2
  34. package/umd/OutOfCanvasUpdater.js +17 -41
  35. package/umd/OutOutMode.js +1 -2
  36. package/103.min.js +0 -2
  37. package/103.min.js.LICENSE.txt +0 -1
  38. package/388.min.js +0 -2
  39. package/388.min.js.LICENSE.txt +0 -1
  40. package/53.min.js +0 -2
  41. package/53.min.js.LICENSE.txt +0 -1
  42. package/569.min.js +0 -2
  43. package/569.min.js.LICENSE.txt +0 -1
  44. package/886.min.js +0 -2
  45. package/886.min.js.LICENSE.txt +0 -1
  46. package/920.min.js +0 -2
  47. package/920.min.js.LICENSE.txt +0 -1
  48. package/dist_browser_BounceOutMode_js.js +0 -30
  49. package/dist_browser_DestroyOutMode_js.js +0 -30
  50. package/dist_browser_NoneOutMode_js.js +0 -30
  51. package/dist_browser_OutOutMode_js.js +0 -30
  52. package/dist_browser_Utils_js.js +0 -30
package/128.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 128.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_updater_out_modes=this.webpackChunk_tsparticles_updater_out_modes||[]).push([[128],{128:(t,i,o)=>{o.d(i,{OutOfCanvasUpdater:()=>d});var e=o(303);class s{constructor(t){this.container=t,this.modes=["bounce","split"]}update(t,i,o,s){if(!this.modes.includes(s))return;const n=this.container;let a=!1;for(const[,e]of n.plugins)if(void 0!==e.particleBounce&&(a=e.particleBounce(t,o,i)),a)break;if(a)return;const r=t.getPosition(),c=t.offset,d=t.getRadius(),u=(0,e.calculateBounds)(r,d),p=n.canvas.size;!function(t){if("bounce"!==t.outMode&&"split"!==t.outMode||"left"!==t.direction&&"right"!==t.direction)return;t.bounds.right<0&&"left"===t.direction?t.particle.position.x=t.size+t.offset.x:t.bounds.left>t.canvasSize.width&&"right"===t.direction&&(t.particle.position.x=t.canvasSize.width-t.size-t.offset.x);const i=t.particle.velocity.x;let o=!1;if("right"===t.direction&&t.bounds.right>=t.canvasSize.width&&i>0||"left"===t.direction&&t.bounds.left<=0&&i<0){const i=(0,e.getRangeValue)(t.particle.options.bounce.horizontal.value);t.particle.velocity.x*=-i,o=!0}if(!o)return;const s=t.offset.x+t.size;t.bounds.right>=t.canvasSize.width&&"right"===t.direction?t.particle.position.x=t.canvasSize.width-s:t.bounds.left<=0&&"left"===t.direction&&(t.particle.position.x=s),"split"===t.outMode&&t.particle.destroy()}({particle:t,outMode:s,direction:i,bounds:u,canvasSize:p,offset:c,size:d}),function(t){if("bounce"!==t.outMode&&"split"!==t.outMode||"bottom"!==t.direction&&"top"!==t.direction)return;t.bounds.bottom<0&&"top"===t.direction?t.particle.position.y=t.size+t.offset.y:t.bounds.top>t.canvasSize.height&&"bottom"===t.direction&&(t.particle.position.y=t.canvasSize.height-t.size-t.offset.y);const i=t.particle.velocity.y;let o=!1;if("bottom"===t.direction&&t.bounds.bottom>=t.canvasSize.height&&i>0||"top"===t.direction&&t.bounds.top<=0&&i<0){const i=(0,e.getRangeValue)(t.particle.options.bounce.vertical.value);t.particle.velocity.y*=-i,o=!0}if(!o)return;const s=t.offset.y+t.size;t.bounds.bottom>=t.canvasSize.height&&"bottom"===t.direction?t.particle.position.y=t.canvasSize.height-s:t.bounds.top<=0&&"top"===t.direction&&(t.particle.position.y=s),"split"===t.outMode&&t.particle.destroy()}({particle:t,outMode:s,direction:i,bounds:u,canvasSize:p,offset:c,size:d})}}class n{constructor(t){this.container=t,this.modes=["destroy"]}update(t,i,o,s){if(!this.modes.includes(s))return;const n=this.container;switch(t.outType){case"normal":case"outside":if((0,e.isPointInside)(t.position,n.canvas.size,e.Vector.origin,t.getRadius(),i))return;break;case"inside":{const{dx:i,dy:o}=(0,e.getDistances)(t.position,t.moveCenter),{x:s,y:n}=t.velocity;if(s<0&&i>t.moveCenter.radius||n<0&&o>t.moveCenter.radius||s>=0&&i<-t.moveCenter.radius||n>=0&&o<-t.moveCenter.radius)return;break}}n.particles.remove(t,void 0,!0)}}class a{constructor(t){this.container=t,this.modes=["none"]}update(t,i,o,s){if(!this.modes.includes(s))return;if((t.options.move.distance.horizontal&&("left"===i||"right"===i))??(t.options.move.distance.vertical&&("top"===i||"bottom"===i)))return;const n=t.options.move.gravity,a=this.container,r=a.canvas.size,c=t.getRadius();if(n.enable){const o=t.position;(!n.inverse&&o.y>r.height+c&&"bottom"===i||n.inverse&&o.y<-c&&"top"===i)&&a.particles.remove(t)}else{if(t.velocity.y>0&&t.position.y<=r.height+c||t.velocity.y<0&&t.position.y>=-c||t.velocity.x>0&&t.position.x<=r.width+c||t.velocity.x<0&&t.position.x>=-c)return;(0,e.isPointInside)(t.position,a.canvas.size,e.Vector.origin,c,i)||a.particles.remove(t)}}}class r{constructor(t){this.container=t,this.modes=["out"]}update(t,i,o,s){if(!this.modes.includes(s))return;const n=this.container;switch(t.outType){case"inside":{const{x:i,y:o}=t.velocity,s=e.Vector.origin;s.length=t.moveCenter.radius,s.angle=t.velocity.angle+Math.PI,s.addTo(e.Vector.create(t.moveCenter));const{dx:a,dy:r}=(0,e.getDistances)(t.position,s);if(i<=0&&a>=0||o<=0&&r>=0||i>=0&&a<=0||o>=0&&r<=0)return;t.position.x=Math.floor((0,e.randomInRange)({min:0,max:n.canvas.size.width})),t.position.y=Math.floor((0,e.randomInRange)({min:0,max:n.canvas.size.height}));const{dx:c,dy:d}=(0,e.getDistances)(t.position,t.moveCenter);t.direction=Math.atan2(-d,-c),t.velocity.angle=t.direction;break}default:if((0,e.isPointInside)(t.position,n.canvas.size,e.Vector.origin,t.getRadius(),i))return;switch(t.outType){case"outside":{t.position.x=Math.floor((0,e.randomInRange)({min:-t.moveCenter.radius,max:t.moveCenter.radius}))+t.moveCenter.x,t.position.y=Math.floor((0,e.randomInRange)({min:-t.moveCenter.radius,max:t.moveCenter.radius}))+t.moveCenter.y;const{dx:i,dy:o}=(0,e.getDistances)(t.position,t.moveCenter);t.moveCenter.radius&&(t.direction=Math.atan2(o,i),t.velocity.angle=t.direction);break}case"normal":{const o=t.options.move.warp,s=n.canvas.size,a={bottom:s.height+t.getRadius()+t.offset.y,left:-t.getRadius()-t.offset.x,right:s.width+t.getRadius()+t.offset.x,top:-t.getRadius()-t.offset.y},r=t.getRadius(),c=(0,e.calculateBounds)(t.position,r);"right"===i&&c.left>s.width+t.offset.x?(t.position.x=a.left,t.initialPosition.x=t.position.x,o||(t.position.y=(0,e.getRandom)()*s.height,t.initialPosition.y=t.position.y)):"left"===i&&c.right<-t.offset.x&&(t.position.x=a.right,t.initialPosition.x=t.position.x,o||(t.position.y=(0,e.getRandom)()*s.height,t.initialPosition.y=t.position.y)),"bottom"===i&&c.top>s.height+t.offset.y?(o||(t.position.x=(0,e.getRandom)()*s.width,t.initialPosition.x=t.position.x),t.position.y=a.top,t.initialPosition.y=t.position.y):"top"===i&&c.bottom<-t.offset.y&&(o||(t.position.x=(0,e.getRandom)()*s.width,t.initialPosition.x=t.position.x),t.position.y=a.bottom,t.initialPosition.y=t.position.y);break}}}}}const c=(t,i)=>t.default===i||t.bottom===i||t.left===i||t.right===i||t.top===i;class d{constructor(t){this._updateOutMode=(t,i,o,e)=>{for(const s of this.updaters)s.update(t,e,i,o)},this.container=t,this.updaters=[]}init(t){this.updaters=[];const i=t.options.move.outModes;c(i,"bounce")?this.updaters.push(new s(this.container)):c(i,"out")?this.updaters.push(new r(this.container)):c(i,"destroy")?this.updaters.push(new n(this.container)):c(i,"none")&&this.updaters.push(new a(this.container))}isEnabled(t){return!t.destroyed&&!t.spawning}update(t,i){const o=t.options.move.outModes;this._updateOutMode(t,i,o.bottom??o.default,"bottom"),this._updateOutMode(t,i,o.left??o.default,"left"),this._updateOutMode(t,i,o.right??o.default,"right"),this._updateOutMode(t,i,o.top??o.default,"top")}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Out Modes Updater v3.3.0 by Matteo Bruni */
@@ -1,4 +1,5 @@
1
1
  import { 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;
@@ -7,7 +8,7 @@ export class BounceOutMode {
7
8
  "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
  }
@@ -5,7 +5,7 @@ export class DestroyOutMode {
5
5
  this.container = container;
6
6
  this.modes = ["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
  }
@@ -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
  }
@@ -5,7 +5,7 @@ export class NoneOutMode {
5
5
  this.container = container;
6
6
  this.modes = ["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
  }
@@ -36,6 +36,5 @@ export class NoneOutMode {
36
36
  container.particles.remove(particle);
37
37
  }
38
38
  }
39
- await Promise.resolve();
40
39
  }
41
40
  }
@@ -1,3 +1,7 @@
1
+ import { BounceOutMode } from "./BounceOutMode.js";
2
+ import { DestroyOutMode } from "./DestroyOutMode.js";
3
+ import { NoneOutMode } from "./NoneOutMode.js";
4
+ import { OutOutMode } from "./OutOutMode.js";
1
5
  const checkOutMode = (outModes, outMode) => {
2
6
  return (outModes.default === outMode ||
3
7
  outModes.bottom === outMode ||
@@ -7,42 +11,38 @@ const checkOutMode = (outModes, outMode) => {
7
11
  };
8
12
  export class OutOfCanvasUpdater {
9
13
  constructor(container) {
10
- this._updateOutMode = async (particle, delta, outMode, direction) => {
14
+ this._updateOutMode = (particle, delta, outMode, direction) => {
11
15
  for (const updater of this.updaters) {
12
- await updater.update(particle, direction, delta, outMode);
16
+ updater.update(particle, direction, delta, outMode);
13
17
  }
14
18
  };
15
19
  this.container = container;
16
20
  this.updaters = [];
17
21
  }
18
- async init(particle) {
22
+ init(particle) {
19
23
  this.updaters = [];
20
24
  const outModes = particle.options.move.outModes;
21
25
  if (checkOutMode(outModes, "bounce")) {
22
- const { BounceOutMode } = await import("./BounceOutMode.js");
23
26
  this.updaters.push(new BounceOutMode(this.container));
24
27
  }
25
28
  else if (checkOutMode(outModes, "out")) {
26
- const { OutOutMode } = await import("./OutOutMode.js");
27
29
  this.updaters.push(new OutOutMode(this.container));
28
30
  }
29
31
  else if (checkOutMode(outModes, "destroy")) {
30
- const { DestroyOutMode } = await import("./DestroyOutMode.js");
31
32
  this.updaters.push(new DestroyOutMode(this.container));
32
33
  }
33
34
  else if (checkOutMode(outModes, "none")) {
34
- const { NoneOutMode } = await import("./NoneOutMode.js");
35
35
  this.updaters.push(new NoneOutMode(this.container));
36
36
  }
37
37
  }
38
38
  isEnabled(particle) {
39
39
  return !particle.destroyed && !particle.spawning;
40
40
  }
41
- async update(particle, delta) {
41
+ update(particle, delta) {
42
42
  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");
43
+ this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom");
44
+ this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left");
45
+ this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right");
46
+ this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top");
47
47
  }
48
48
  }
@@ -5,7 +5,7 @@ export class OutOutMode {
5
5
  this.container = container;
6
6
  this.modes = ["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
  }
@@ -107,6 +107,5 @@ export class OutOutMode {
107
107
  break;
108
108
  }
109
109
  }
110
- await Promise.resolve();
111
110
  }
112
111
  }
@@ -1,30 +1,8 @@
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;
@@ -33,7 +11,7 @@ class BounceOutMode {
33
11
  "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;
@@ -8,7 +8,7 @@ class DestroyOutMode {
8
8
  this.container = container;
9
9
  this.modes = ["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
  }
@@ -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;
@@ -8,7 +8,7 @@ class NoneOutMode {
8
8
  this.container = container;
9
9
  this.modes = ["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
  }
@@ -39,7 +39,6 @@ class NoneOutMode {
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,10 @@
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 BounceOutMode_js_1 = require("./BounceOutMode.js");
5
+ const DestroyOutMode_js_1 = require("./DestroyOutMode.js");
6
+ const NoneOutMode_js_1 = require("./NoneOutMode.js");
7
+ const OutOutMode_js_1 = require("./OutOutMode.js");
27
8
  const checkOutMode = (outModes, outMode) => {
28
9
  return (outModes.default === outMode ||
29
10
  outModes.bottom === outMode ||
@@ -33,43 +14,39 @@ const checkOutMode = (outModes, outMode) => {
33
14
  };
34
15
  class OutOfCanvasUpdater {
35
16
  constructor(container) {
36
- this._updateOutMode = async (particle, delta, outMode, direction) => {
17
+ this._updateOutMode = (particle, delta, outMode, direction) => {
37
18
  for (const updater of this.updaters) {
38
- await updater.update(particle, direction, delta, outMode);
19
+ updater.update(particle, direction, delta, outMode);
39
20
  }
40
21
  };
41
22
  this.container = container;
42
23
  this.updaters = [];
43
24
  }
44
- async init(particle) {
25
+ init(particle) {
45
26
  this.updaters = [];
46
27
  const outModes = particle.options.move.outModes;
47
28
  if (checkOutMode(outModes, "bounce")) {
48
- const { BounceOutMode } = await Promise.resolve().then(() => __importStar(require("./BounceOutMode.js")));
49
- this.updaters.push(new BounceOutMode(this.container));
29
+ this.updaters.push(new BounceOutMode_js_1.BounceOutMode(this.container));
50
30
  }
51
31
  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
+ this.updaters.push(new OutOutMode_js_1.OutOutMode(this.container));
54
33
  }
55
34
  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
+ this.updaters.push(new DestroyOutMode_js_1.DestroyOutMode(this.container));
58
36
  }
59
37
  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
+ this.updaters.push(new NoneOutMode_js_1.NoneOutMode(this.container));
62
39
  }
63
40
  }
64
41
  isEnabled(particle) {
65
42
  return !particle.destroyed && !particle.spawning;
66
43
  }
67
- async update(particle, delta) {
44
+ update(particle, delta) {
68
45
  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");
46
+ this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom");
47
+ this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left");
48
+ this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right");
49
+ this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top");
73
50
  }
74
51
  }
75
52
  exports.OutOfCanvasUpdater = OutOfCanvasUpdater;
package/cjs/OutOutMode.js CHANGED
@@ -8,7 +8,7 @@ class OutOutMode {
8
8
  this.container = container;
9
9
  this.modes = ["out"];
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
  }
@@ -110,7 +110,6 @@ class OutOutMode {
110
110
  break;
111
111
  }
112
112
  }
113
- await Promise.resolve();
114
113
  }
115
114
  }
116
115
  exports.OutOutMode = OutOutMode;
package/cjs/index.js CHANGED
@@ -1,32 +1,9 @@
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.loadOutModesUpdater = void 0;
27
4
  async function loadOutModesUpdater(engine, refresh = true) {
28
5
  await engine.addParticleUpdater("outModes", async (container) => {
29
- const { OutOfCanvasUpdater } = await Promise.resolve().then(() => __importStar(require("./OutOfCanvasUpdater.js")));
6
+ const { OutOfCanvasUpdater } = await import("./OutOfCanvasUpdater.js");
30
7
  return new OutOfCanvasUpdater(container);
31
8
  }, refresh);
32
9
  }
@@ -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.2.1
7
+ * v3.3.0
8
8
  */
9
9
  "use strict";
10
10
  /*
@@ -17,13 +17,63 @@
17
17
  */
18
18
  (this["webpackChunk_tsparticles_updater_out_modes"] = this["webpackChunk_tsparticles_updater_out_modes"] || []).push([["dist_browser_OutOfCanvasUpdater_js"],{
19
19
 
20
+ /***/ "./dist/browser/BounceOutMode.js":
21
+ /*!***************************************!*\
22
+ !*** ./dist/browser/BounceOutMode.js ***!
23
+ \***************************************/
24
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
25
+
26
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BounceOutMode: () => (/* binding */ BounceOutMode)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\nclass BounceOutMode {\n constructor(container) {\n this.container = container;\n this.modes = [\"bounce\", \"split\"];\n }\n update(particle, direction, delta, outMode) {\n if (!this.modes.includes(outMode)) {\n return;\n }\n const container = this.container;\n let handled = false;\n for (const [, plugin] of container.plugins) {\n if (plugin.particleBounce !== undefined) {\n handled = plugin.particleBounce(particle, delta, direction);\n }\n if (handled) {\n break;\n }\n }\n if (handled) {\n return;\n }\n const pos = particle.getPosition(),\n offset = particle.offset,\n size = particle.getRadius(),\n bounds = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.calculateBounds)(pos, size),\n canvasSize = container.canvas.size;\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.bounceHorizontal)({\n particle,\n outMode,\n direction,\n bounds,\n canvasSize,\n offset,\n size\n });\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.bounceVertical)({\n particle,\n outMode,\n direction,\n bounds,\n canvasSize,\n offset,\n size\n });\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/BounceOutMode.js?");
27
+
28
+ /***/ }),
29
+
30
+ /***/ "./dist/browser/DestroyOutMode.js":
31
+ /*!****************************************!*\
32
+ !*** ./dist/browser/DestroyOutMode.js ***!
33
+ \****************************************/
34
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
35
+
36
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DestroyOutMode: () => (/* binding */ DestroyOutMode)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst minVelocity = 0;\nclass DestroyOutMode {\n constructor(container) {\n this.container = container;\n this.modes = [\"destroy\"];\n }\n update(particle, direction, _delta, outMode) {\n if (!this.modes.includes(outMode)) {\n return;\n }\n const container = this.container;\n switch (particle.outType) {\n case \"normal\":\n case \"outside\":\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isPointInside)(particle.position, container.canvas.size, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin, particle.getRadius(), direction)) {\n return;\n }\n break;\n case \"inside\":\n {\n const {\n dx,\n dy\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(particle.position, particle.moveCenter),\n {\n x: vx,\n y: vy\n } = particle.velocity;\n if (vx < minVelocity && dx > particle.moveCenter.radius || vy < minVelocity && dy > particle.moveCenter.radius || vx >= minVelocity && dx < -particle.moveCenter.radius || vy >= minVelocity && dy < -particle.moveCenter.radius) {\n return;\n }\n break;\n }\n }\n container.particles.remove(particle, undefined, true);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/DestroyOutMode.js?");
37
+
38
+ /***/ }),
39
+
40
+ /***/ "./dist/browser/NoneOutMode.js":
41
+ /*!*************************************!*\
42
+ !*** ./dist/browser/NoneOutMode.js ***!
43
+ \*************************************/
44
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
45
+
46
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ NoneOutMode: () => (/* binding */ NoneOutMode)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst minVelocity = 0;\nclass NoneOutMode {\n constructor(container) {\n this.container = container;\n this.modes = [\"none\"];\n }\n update(particle, direction, delta, outMode) {\n if (!this.modes.includes(outMode)) {\n return;\n }\n if ((particle.options.move.distance.horizontal && (direction === \"left\" || direction === \"right\")) ?? (particle.options.move.distance.vertical && (direction === \"top\" || direction === \"bottom\"))) {\n return;\n }\n const gravityOptions = particle.options.move.gravity,\n container = this.container,\n canvasSize = container.canvas.size,\n pRadius = particle.getRadius();\n if (!gravityOptions.enable) {\n if (particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius || particle.velocity.y < minVelocity && particle.position.y >= -pRadius || particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius || particle.velocity.x < minVelocity && particle.position.x >= -pRadius) {\n return;\n }\n if (!(0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isPointInside)(particle.position, container.canvas.size, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin, pRadius, direction)) {\n container.particles.remove(particle);\n }\n } else {\n const position = particle.position;\n if (!gravityOptions.inverse && position.y > canvasSize.height + pRadius && direction === \"bottom\" || gravityOptions.inverse && position.y < -pRadius && direction === \"top\") {\n container.particles.remove(particle);\n }\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/NoneOutMode.js?");
47
+
48
+ /***/ }),
49
+
20
50
  /***/ "./dist/browser/OutOfCanvasUpdater.js":
21
51
  /*!********************************************!*\
22
52
  !*** ./dist/browser/OutOfCanvasUpdater.js ***!
23
53
  \********************************************/
24
54
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
25
55
 
26
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ OutOfCanvasUpdater: () => (/* binding */ OutOfCanvasUpdater)\n/* harmony export */ });\nconst checkOutMode = (outModes, outMode) => {\n return outModes.default === outMode || outModes.bottom === outMode || outModes.left === outMode || outModes.right === outMode || outModes.top === outMode;\n};\nclass OutOfCanvasUpdater {\n constructor(container) {\n this._updateOutMode = async (particle, delta, outMode, direction) => {\n for (const updater of this.updaters) {\n await updater.update(particle, direction, delta, outMode);\n }\n };\n this.container = container;\n this.updaters = [];\n }\n async init(particle) {\n this.updaters = [];\n const outModes = particle.options.move.outModes;\n if (checkOutMode(outModes, \"bounce\")) {\n const {\n BounceOutMode\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_BounceOutMode_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./BounceOutMode.js */ \"./dist/browser/BounceOutMode.js\"));\n this.updaters.push(new BounceOutMode(this.container));\n } else if (checkOutMode(outModes, \"out\")) {\n const {\n OutOutMode\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_OutOutMode_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./OutOutMode.js */ \"./dist/browser/OutOutMode.js\"));\n this.updaters.push(new OutOutMode(this.container));\n } else if (checkOutMode(outModes, \"destroy\")) {\n const {\n DestroyOutMode\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_DestroyOutMode_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./DestroyOutMode.js */ \"./dist/browser/DestroyOutMode.js\"));\n this.updaters.push(new DestroyOutMode(this.container));\n } else if (checkOutMode(outModes, \"none\")) {\n const {\n NoneOutMode\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_NoneOutMode_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./NoneOutMode.js */ \"./dist/browser/NoneOutMode.js\"));\n this.updaters.push(new NoneOutMode(this.container));\n }\n }\n isEnabled(particle) {\n return !particle.destroyed && !particle.spawning;\n }\n async update(particle, delta) {\n const outModes = particle.options.move.outModes;\n await this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, \"bottom\");\n await this._updateOutMode(particle, delta, outModes.left ?? outModes.default, \"left\");\n await this._updateOutMode(particle, delta, outModes.right ?? outModes.default, \"right\");\n await this._updateOutMode(particle, delta, outModes.top ?? outModes.default, \"top\");\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/OutOfCanvasUpdater.js?");
56
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ OutOfCanvasUpdater: () => (/* binding */ OutOfCanvasUpdater)\n/* harmony export */ });\n/* harmony import */ var _BounceOutMode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BounceOutMode.js */ \"./dist/browser/BounceOutMode.js\");\n/* harmony import */ var _DestroyOutMode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./DestroyOutMode.js */ \"./dist/browser/DestroyOutMode.js\");\n/* harmony import */ var _NoneOutMode_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./NoneOutMode.js */ \"./dist/browser/NoneOutMode.js\");\n/* harmony import */ var _OutOutMode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./OutOutMode.js */ \"./dist/browser/OutOutMode.js\");\n\n\n\n\nconst checkOutMode = (outModes, outMode) => {\n return outModes.default === outMode || outModes.bottom === outMode || outModes.left === outMode || outModes.right === outMode || outModes.top === outMode;\n};\nclass OutOfCanvasUpdater {\n constructor(container) {\n this._updateOutMode = (particle, delta, outMode, direction) => {\n for (const updater of this.updaters) {\n updater.update(particle, direction, delta, outMode);\n }\n };\n this.container = container;\n this.updaters = [];\n }\n init(particle) {\n this.updaters = [];\n const outModes = particle.options.move.outModes;\n if (checkOutMode(outModes, \"bounce\")) {\n this.updaters.push(new _BounceOutMode_js__WEBPACK_IMPORTED_MODULE_0__.BounceOutMode(this.container));\n } else if (checkOutMode(outModes, \"out\")) {\n this.updaters.push(new _OutOutMode_js__WEBPACK_IMPORTED_MODULE_1__.OutOutMode(this.container));\n } else if (checkOutMode(outModes, \"destroy\")) {\n this.updaters.push(new _DestroyOutMode_js__WEBPACK_IMPORTED_MODULE_2__.DestroyOutMode(this.container));\n } else if (checkOutMode(outModes, \"none\")) {\n this.updaters.push(new _NoneOutMode_js__WEBPACK_IMPORTED_MODULE_3__.NoneOutMode(this.container));\n }\n }\n isEnabled(particle) {\n return !particle.destroyed && !particle.spawning;\n }\n update(particle, delta) {\n const outModes = particle.options.move.outModes;\n this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, \"bottom\");\n this._updateOutMode(particle, delta, outModes.left ?? outModes.default, \"left\");\n this._updateOutMode(particle, delta, outModes.right ?? outModes.default, \"right\");\n this._updateOutMode(particle, delta, outModes.top ?? outModes.default, \"top\");\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/OutOfCanvasUpdater.js?");
57
+
58
+ /***/ }),
59
+
60
+ /***/ "./dist/browser/OutOutMode.js":
61
+ /*!************************************!*\
62
+ !*** ./dist/browser/OutOutMode.js ***!
63
+ \************************************/
64
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
65
+
66
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ OutOutMode: () => (/* binding */ OutOutMode)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst minVelocity = 0,\n minDistance = 0;\nclass OutOutMode {\n constructor(container) {\n this.container = container;\n this.modes = [\"out\"];\n }\n update(particle, direction, delta, outMode) {\n if (!this.modes.includes(outMode)) {\n return;\n }\n const container = this.container;\n switch (particle.outType) {\n case \"inside\":\n {\n const {\n x: vx,\n y: vy\n } = particle.velocity;\n const circVec = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n circVec.length = particle.moveCenter.radius;\n circVec.angle = particle.velocity.angle + Math.PI;\n circVec.addTo(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.create(particle.moveCenter));\n const {\n dx,\n dy\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(particle.position, circVec);\n if (vx <= minVelocity && dx >= minDistance || vy <= minVelocity && dy >= minDistance || vx >= minVelocity && dx <= minDistance || vy >= minVelocity && dy <= minDistance) {\n return;\n }\n particle.position.x = Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRange)({\n min: 0,\n max: container.canvas.size.width\n }));\n particle.position.y = Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRange)({\n min: 0,\n max: container.canvas.size.height\n }));\n const {\n dx: newDx,\n dy: newDy\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(particle.position, particle.moveCenter);\n particle.direction = Math.atan2(-newDy, -newDx);\n particle.velocity.angle = particle.direction;\n break;\n }\n default:\n {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isPointInside)(particle.position, container.canvas.size, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin, particle.getRadius(), direction)) {\n return;\n }\n switch (particle.outType) {\n case \"outside\":\n {\n particle.position.x = Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRange)({\n min: -particle.moveCenter.radius,\n max: particle.moveCenter.radius\n })) + particle.moveCenter.x;\n particle.position.y = Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRange)({\n min: -particle.moveCenter.radius,\n max: particle.moveCenter.radius\n })) + particle.moveCenter.y;\n const {\n dx,\n dy\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(particle.position, particle.moveCenter);\n if (particle.moveCenter.radius) {\n particle.direction = Math.atan2(dy, dx);\n particle.velocity.angle = particle.direction;\n }\n break;\n }\n case \"normal\":\n {\n const warp = particle.options.move.warp,\n canvasSize = container.canvas.size,\n newPos = {\n bottom: canvasSize.height + particle.getRadius() + particle.offset.y,\n left: -particle.getRadius() - particle.offset.x,\n right: canvasSize.width + particle.getRadius() + particle.offset.x,\n top: -particle.getRadius() - particle.offset.y\n },\n sizeValue = particle.getRadius(),\n nextBounds = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.calculateBounds)(particle.position, sizeValue);\n if (direction === \"right\" && nextBounds.left > canvasSize.width + particle.offset.x) {\n particle.position.x = newPos.left;\n particle.initialPosition.x = particle.position.x;\n if (!warp) {\n particle.position.y = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * canvasSize.height;\n particle.initialPosition.y = particle.position.y;\n }\n } else if (direction === \"left\" && nextBounds.right < -particle.offset.x) {\n particle.position.x = newPos.right;\n particle.initialPosition.x = particle.position.x;\n if (!warp) {\n particle.position.y = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * canvasSize.height;\n particle.initialPosition.y = particle.position.y;\n }\n }\n if (direction === \"bottom\" && nextBounds.top > canvasSize.height + particle.offset.y) {\n if (!warp) {\n particle.position.x = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * canvasSize.width;\n particle.initialPosition.x = particle.position.x;\n }\n particle.position.y = newPos.top;\n particle.initialPosition.y = particle.position.y;\n } else if (direction === \"top\" && nextBounds.bottom < -particle.offset.y) {\n if (!warp) {\n particle.position.x = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * canvasSize.width;\n particle.initialPosition.x = particle.position.x;\n }\n particle.position.y = newPos.bottom;\n particle.initialPosition.y = particle.position.y;\n }\n break;\n }\n }\n break;\n }\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/OutOutMode.js?");
67
+
68
+ /***/ }),
69
+
70
+ /***/ "./dist/browser/Utils.js":
71
+ /*!*******************************!*\
72
+ !*** ./dist/browser/Utils.js ***!
73
+ \*******************************/
74
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
75
+
76
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ bounceHorizontal: () => (/* binding */ bounceHorizontal),\n/* harmony export */ bounceVertical: () => (/* binding */ bounceVertical)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst minVelocity = 0,\n boundsMin = 0;\nfunction bounceHorizontal(data) {\n if (data.outMode !== \"bounce\" && data.outMode !== \"split\" || data.direction !== \"left\" && data.direction !== \"right\") {\n return;\n }\n if (data.bounds.right < boundsMin && data.direction === \"left\") {\n data.particle.position.x = data.size + data.offset.x;\n } else if (data.bounds.left > data.canvasSize.width && data.direction === \"right\") {\n data.particle.position.x = data.canvasSize.width - data.size - data.offset.x;\n }\n const velocity = data.particle.velocity.x;\n let bounced = false;\n if (data.direction === \"right\" && data.bounds.right >= data.canvasSize.width && velocity > minVelocity || data.direction === \"left\" && data.bounds.left <= boundsMin && velocity < minVelocity) {\n const newVelocity = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(data.particle.options.bounce.horizontal.value);\n data.particle.velocity.x *= -newVelocity;\n bounced = true;\n }\n if (!bounced) {\n return;\n }\n const minPos = data.offset.x + data.size;\n if (data.bounds.right >= data.canvasSize.width && data.direction === \"right\") {\n data.particle.position.x = data.canvasSize.width - minPos;\n } else if (data.bounds.left <= boundsMin && data.direction === \"left\") {\n data.particle.position.x = minPos;\n }\n if (data.outMode === \"split\") {\n data.particle.destroy();\n }\n}\nfunction bounceVertical(data) {\n if (data.outMode !== \"bounce\" && data.outMode !== \"split\" || data.direction !== \"bottom\" && data.direction !== \"top\") {\n return;\n }\n if (data.bounds.bottom < boundsMin && data.direction === \"top\") {\n data.particle.position.y = data.size + data.offset.y;\n } else if (data.bounds.top > data.canvasSize.height && data.direction === \"bottom\") {\n data.particle.position.y = data.canvasSize.height - data.size - data.offset.y;\n }\n const velocity = data.particle.velocity.y;\n let bounced = false;\n if (data.direction === \"bottom\" && data.bounds.bottom >= data.canvasSize.height && velocity > minVelocity || data.direction === \"top\" && data.bounds.top <= boundsMin && velocity < minVelocity) {\n const newVelocity = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(data.particle.options.bounce.vertical.value);\n data.particle.velocity.y *= -newVelocity;\n bounced = true;\n }\n if (!bounced) {\n return;\n }\n const minPos = data.offset.y + data.size;\n if (data.bounds.bottom >= data.canvasSize.height && data.direction === \"bottom\") {\n data.particle.position.y = data.canvasSize.height - minPos;\n } else if (data.bounds.top <= boundsMin && data.direction === \"top\") {\n data.particle.position.y = minPos;\n }\n if (data.outMode === \"split\") {\n data.particle.destroy();\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/Utils.js?");
27
77
 
28
78
  /***/ })
29
79
 
@@ -1,4 +1,5 @@
1
1
  import { 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;
@@ -7,7 +8,7 @@ export class BounceOutMode {
7
8
  "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
  }
@@ -5,7 +5,7 @@ export class DestroyOutMode {
5
5
  this.container = container;
6
6
  this.modes = ["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
  }
@@ -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
  }
@@ -5,7 +5,7 @@ export class NoneOutMode {
5
5
  this.container = container;
6
6
  this.modes = ["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
  }
@@ -36,6 +36,5 @@ export class NoneOutMode {
36
36
  container.particles.remove(particle);
37
37
  }
38
38
  }
39
- await Promise.resolve();
40
39
  }
41
40
  }