@tsparticles/updater-out-modes 3.1.0 → 3.2.1

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 (58) hide show
  1. package/103.min.js +2 -0
  2. package/103.min.js.LICENSE.txt +1 -0
  3. package/388.min.js +2 -0
  4. package/388.min.js.LICENSE.txt +1 -0
  5. package/53.min.js +2 -0
  6. package/53.min.js.LICENSE.txt +1 -0
  7. package/569.min.js +2 -0
  8. package/569.min.js.LICENSE.txt +1 -0
  9. package/886.min.js +2 -0
  10. package/886.min.js.LICENSE.txt +1 -0
  11. package/920.min.js +2 -0
  12. package/920.min.js.LICENSE.txt +1 -0
  13. package/browser/BounceOutMode.js +3 -8
  14. package/browser/DestroyOutMode.js +3 -3
  15. package/browser/NoneOutMode.js +3 -4
  16. package/browser/OutOfCanvasUpdater.js +34 -18
  17. package/browser/OutOutMode.js +2 -1
  18. package/browser/Utils.js +2 -8
  19. package/browser/index.js +4 -2
  20. package/cjs/BounceOutMode.js +28 -10
  21. package/cjs/DestroyOutMode.js +3 -3
  22. package/cjs/NoneOutMode.js +3 -4
  23. package/cjs/OutOfCanvasUpdater.js +57 -18
  24. package/cjs/OutOutMode.js +2 -1
  25. package/cjs/Utils.js +2 -8
  26. package/cjs/index.js +27 -2
  27. package/dist_browser_BounceOutMode_js.js +30 -0
  28. package/dist_browser_DestroyOutMode_js.js +30 -0
  29. package/dist_browser_NoneOutMode_js.js +30 -0
  30. package/dist_browser_OutOfCanvasUpdater_js.js +30 -0
  31. package/dist_browser_OutOutMode_js.js +30 -0
  32. package/dist_browser_Utils_js.js +30 -0
  33. package/esm/BounceOutMode.js +3 -8
  34. package/esm/DestroyOutMode.js +3 -3
  35. package/esm/NoneOutMode.js +3 -4
  36. package/esm/OutOfCanvasUpdater.js +34 -18
  37. package/esm/OutOutMode.js +2 -1
  38. package/esm/Utils.js +2 -8
  39. package/esm/index.js +4 -2
  40. package/package.json +2 -2
  41. package/report.html +3 -3
  42. package/tsparticles.updater.out-modes.js +241 -360
  43. package/tsparticles.updater.out-modes.min.js +1 -1
  44. package/tsparticles.updater.out-modes.min.js.LICENSE.txt +1 -1
  45. package/types/BounceOutMode.d.ts +3 -3
  46. package/types/DestroyOutMode.d.ts +3 -3
  47. package/types/IBounceData.d.ts +2 -2
  48. package/types/IOutModeManager.d.ts +3 -3
  49. package/types/NoneOutMode.d.ts +3 -3
  50. package/types/OutOfCanvasUpdater.d.ts +2 -2
  51. package/types/OutOutMode.d.ts +3 -3
  52. package/umd/BounceOutMode.js +30 -11
  53. package/umd/DestroyOutMode.js +3 -3
  54. package/umd/NoneOutMode.js +3 -4
  55. package/umd/OutOfCanvasUpdater.js +59 -19
  56. package/umd/OutOutMode.js +2 -1
  57. package/umd/Utils.js +2 -8
  58. package/umd/index.js +29 -3
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.updater.out-modes.min.js.LICENSE.txt */
2
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var o="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var i in o)("object"==typeof exports?exports:t)[i]=o[i]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},o={};function i(t){var n=o[t];if(void 0!==n)return n.exports;var s=o[t]={exports:{}};return e[t](s,s.exports,i),s.exports}i.d=(t,e)=>{for(var o in e)i.o(e,o)&&!i.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{i.r(n),i.d(n,{loadOutModesUpdater:()=>c});var t=i(533);class e{constructor(t){this.container=t,this.modes=["bounce","bounce-vertical","bounce-horizontal","bounceVertical","bounceHorizontal","split"]}update(e,o,i,n){if(!this.modes.includes(n))return;const s=this.container;let r=!1;for(const[,t]of s.plugins)if(void 0!==t.particleBounce&&(r=t.particleBounce(e,i,o)),r)break;if(r)return;const a=e.getPosition(),c=e.offset,d=e.getRadius(),u=(0,t.calculateBounds)(a,d),p=s.canvas.size;!function(e){if("bounce"!==e.outMode&&"bounce-horizontal"!==e.outMode&&"bounceHorizontal"!==e.outMode&&"split"!==e.outMode||"left"!==e.direction&&"right"!==e.direction)return;e.bounds.right<0&&"left"===e.direction?e.particle.position.x=e.size+e.offset.x:e.bounds.left>e.canvasSize.width&&"right"===e.direction&&(e.particle.position.x=e.canvasSize.width-e.size-e.offset.x);const o=e.particle.velocity.x;let i=!1;if("right"===e.direction&&e.bounds.right>=e.canvasSize.width&&o>0||"left"===e.direction&&e.bounds.left<=0&&o<0){const o=(0,t.getRangeValue)(e.particle.options.bounce.horizontal.value);e.particle.velocity.x*=-o,i=!0}if(!i)return;const n=e.offset.x+e.size;e.bounds.right>=e.canvasSize.width&&"right"===e.direction?e.particle.position.x=e.canvasSize.width-n:e.bounds.left<=0&&"left"===e.direction&&(e.particle.position.x=n),"split"===e.outMode&&e.particle.destroy()}({particle:e,outMode:n,direction:o,bounds:u,canvasSize:p,offset:c,size:d}),function(e){if("bounce"!==e.outMode&&"bounce-vertical"!==e.outMode&&"bounceVertical"!==e.outMode&&"split"!==e.outMode||"bottom"!==e.direction&&"top"!==e.direction)return;e.bounds.bottom<0&&"top"===e.direction?e.particle.position.y=e.size+e.offset.y:e.bounds.top>e.canvasSize.height&&"bottom"===e.direction&&(e.particle.position.y=e.canvasSize.height-e.size-e.offset.y);const o=e.particle.velocity.y;let i=!1;if("bottom"===e.direction&&e.bounds.bottom>=e.canvasSize.height&&o>0||"top"===e.direction&&e.bounds.top<=0&&o<0){const o=(0,t.getRangeValue)(e.particle.options.bounce.vertical.value);e.particle.velocity.y*=-o,i=!0}if(!i)return;const n=e.offset.y+e.size;e.bounds.bottom>=e.canvasSize.height&&"bottom"===e.direction?e.particle.position.y=e.canvasSize.height-n:e.bounds.top<=0&&"top"===e.direction&&(e.particle.position.y=n),"split"===e.outMode&&e.particle.destroy()}({particle:e,outMode:n,direction:o,bounds:u,canvasSize:p,offset:c,size:d})}}class o{constructor(t){this.container=t,this.modes=["destroy"]}update(e,o,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(e.outType){case"normal":case"outside":if((0,t.isPointInside)(e.position,s.canvas.size,t.Vector.origin,e.getRadius(),o))return;break;case"inside":{const{dx:o,dy:i}=(0,t.getDistances)(e.position,e.moveCenter),{x:n,y:s}=e.velocity;if(n<0&&o>e.moveCenter.radius||s<0&&i>e.moveCenter.radius||n>=0&&o<-e.moveCenter.radius||s>=0&&i<-e.moveCenter.radius)return;break}}s.particles.remove(e,void 0,!0)}}class s{constructor(t){this.container=t,this.modes=["none"]}update(e,o,i,n){if(!this.modes.includes(n))return;if((e.options.move.distance.horizontal&&("left"===o||"right"===o))??(e.options.move.distance.vertical&&("top"===o||"bottom"===o)))return;const s=e.options.move.gravity,r=this.container,a=r.canvas.size,c=e.getRadius();if(s.enable){const t=e.position;(!s.inverse&&t.y>a.height+c&&"bottom"===o||s.inverse&&t.y<-c&&"top"===o)&&r.particles.remove(e)}else{if(e.velocity.y>0&&e.position.y<=a.height+c||e.velocity.y<0&&e.position.y>=-c||e.velocity.x>0&&e.position.x<=a.width+c||e.velocity.x<0&&e.position.x>=-c)return;(0,t.isPointInside)(e.position,r.canvas.size,t.Vector.origin,c,o)||r.particles.remove(e)}}}class r{constructor(t){this.container=t,this.modes=["out"]}update(e,o,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(e.outType){case"inside":{const{x:o,y:i}=e.velocity,n=t.Vector.origin;n.length=e.moveCenter.radius,n.angle=e.velocity.angle+Math.PI,n.addTo(t.Vector.create(e.moveCenter));const{dx:r,dy:a}=(0,t.getDistances)(e.position,n);if(o<=0&&r>=0||i<=0&&a>=0||o>=0&&r<=0||i>=0&&a<=0)return;e.position.x=Math.floor((0,t.randomInRange)({min:0,max:s.canvas.size.width})),e.position.y=Math.floor((0,t.randomInRange)({min:0,max:s.canvas.size.height}));const{dx:c,dy:d}=(0,t.getDistances)(e.position,e.moveCenter);e.direction=Math.atan2(-d,-c),e.velocity.angle=e.direction;break}default:if((0,t.isPointInside)(e.position,s.canvas.size,t.Vector.origin,e.getRadius(),o))return;switch(e.outType){case"outside":{e.position.x=Math.floor((0,t.randomInRange)({min:-e.moveCenter.radius,max:e.moveCenter.radius}))+e.moveCenter.x,e.position.y=Math.floor((0,t.randomInRange)({min:-e.moveCenter.radius,max:e.moveCenter.radius}))+e.moveCenter.y;const{dx:o,dy:i}=(0,t.getDistances)(e.position,e.moveCenter);e.moveCenter.radius&&(e.direction=Math.atan2(i,o),e.velocity.angle=e.direction);break}case"normal":{const i=e.options.move.warp,n=s.canvas.size,r={bottom:n.height+e.getRadius()+e.offset.y,left:-e.getRadius()-e.offset.x,right:n.width+e.getRadius()+e.offset.x,top:-e.getRadius()-e.offset.y},a=e.getRadius(),c=(0,t.calculateBounds)(e.position,a);"right"===o&&c.left>n.width+e.offset.x?(e.position.x=r.left,e.initialPosition.x=e.position.x,i||(e.position.y=(0,t.getRandom)()*n.height,e.initialPosition.y=e.position.y)):"left"===o&&c.right<-e.offset.x&&(e.position.x=r.right,e.initialPosition.x=e.position.x,i||(e.position.y=(0,t.getRandom)()*n.height,e.initialPosition.y=e.position.y)),"bottom"===o&&c.top>n.height+e.offset.y?(i||(e.position.x=(0,t.getRandom)()*n.width,e.initialPosition.x=e.position.x),e.position.y=r.top,e.initialPosition.y=e.position.y):"top"===o&&c.bottom<-e.offset.y&&(i||(e.position.x=(0,t.getRandom)()*n.width,e.initialPosition.x=e.position.x),e.position.y=r.bottom,e.initialPosition.y=e.position.y);break}}}}}class a{constructor(t){this._updateOutMode=(t,e,o,i)=>{for(const n of this.updaters)n.update(t,i,e,o)},this.container=t,this.updaters=[new e(t),new o(t),new r(t),new s(t)]}init(){}isEnabled(t){return!t.destroyed&&!t.spawning}update(t,e){const o=t.options.move.outModes;this._updateOutMode(t,e,o.bottom??o.default,"bottom"),this._updateOutMode(t,e,o.left??o.default,"left"),this._updateOutMode(t,e,o.right??o.default,"right"),this._updateOutMode(t,e,o.top??o.default,"top")}}async function c(t,e=!0){await t.addParticleUpdater("outModes",(t=>new a(t)),e)}})(),n})()));
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 r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{var t,r,o={533:t=>{t.exports=e}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e](r,r.exports,a),r.exports}a.m=o,a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce(((t,r)=>(a.f[r](e,t),t)),[])),a.u=e=>e+".min.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},r="@tsparticles/updater-out-modes:",a.l=(e,o,n,i)=>{if(t[e])t[e].push(o);else{var s,u;if(void 0!==n)for(var d=document.getElementsByTagName("script"),c=0;c<d.length;c++){var p=d[c];if(p.getAttribute("src")==e||p.getAttribute("data-webpack")==r+n){s=p;break}}s||(u=!0,(s=document.createElement("script")).charset="utf-8",s.timeout=120,a.nc&&s.setAttribute("nonce",a.nc),s.setAttribute("data-webpack",r+n),s.src=e),t[e]=[o];var l=(r,o)=>{s.onerror=s.onload=null,clearTimeout(f);var n=t[e];if(delete t[e],s.parentNode&&s.parentNode.removeChild(s),n&&n.forEach((e=>e(o))),r)return r(o)},f=setTimeout(l.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=l.bind(null,s.onerror),s.onload=l.bind(null,s.onload),u&&document.head.appendChild(s)}},a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;a.g.importScripts&&(e=a.g.location+"");var t=a.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&!e;)e=r[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),a.p=e})(),(()=>{var e={847:0};a.f.j=(t,r)=>{var o=a.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var n=new Promise(((r,n)=>o=e[t]=[r,n]));r.push(o[2]=n);var i=a.p+a.u(t),s=new Error;a.l(i,(r=>{if(a.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var n=r&&("load"===r.type?"missing":r.type),i=r&&r.target&&r.target.src;s.message="Loading chunk "+t+" failed.\n("+n+": "+i+")",s.name="ChunkLoadError",s.type=n,s.request=i,o[1](s)}}),"chunk-"+t,t)}};var t=(t,r)=>{var o,n,i=r[0],s=r[1],u=r[2],d=0;if(i.some((t=>0!==e[t]))){for(o in s)a.o(s,o)&&(a.m[o]=s[o]);if(u)u(a)}for(t&&t(r);d<i.length;d++)n=i[d],a.o(e,n)&&e[n]&&e[n][0](),e[n]=0},r=this.webpackChunk_tsparticles_updater_out_modes=this.webpackChunk_tsparticles_updater_out_modes||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var i={};return(()=>{async function e(e,t=!0){await e.addParticleUpdater("outModes",(async e=>{const{OutOfCanvasUpdater:t}=await a.e(53).then(a.bind(a,53));return new t(e)}),t)}a.r(i),a.d(i,{loadOutModesUpdater:()=>e})})(),i})()));
@@ -1 +1 @@
1
- /*! tsParticles Out Modes Updater v3.1.0 by Matteo Bruni */
1
+ /*! tsParticles Out Modes Updater v3.2.1 by Matteo Bruni */
@@ -1,8 +1,8 @@
1
- import { type Container, type IDelta, OutMode, type OutModeAlt, type OutModeDirection, type Particle } from "@tsparticles/engine";
1
+ import { type Container, type IDelta, OutMode, type OutModeDirection, type Particle } from "@tsparticles/engine";
2
2
  import type { IOutModeManager } from "./IOutModeManager.js";
3
3
  export declare class BounceOutMode implements IOutModeManager {
4
4
  private readonly container;
5
- modes: (OutMode | OutModeAlt | keyof typeof OutMode)[];
5
+ modes: (OutMode | keyof typeof OutMode)[];
6
6
  constructor(container: Container);
7
- update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void;
7
+ update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | keyof typeof OutMode): Promise<void>;
8
8
  }
@@ -1,8 +1,8 @@
1
- import { type Container, type IDelta, OutMode, type OutModeAlt, type OutModeDirection, type Particle } from "@tsparticles/engine";
1
+ import { type Container, type IDelta, OutMode, type OutModeDirection, type Particle } from "@tsparticles/engine";
2
2
  import type { IOutModeManager } from "./IOutModeManager.js";
3
3
  export declare class DestroyOutMode implements IOutModeManager {
4
4
  private readonly container;
5
- modes: (OutMode | OutModeAlt | keyof typeof OutMode)[];
5
+ modes: (OutMode | keyof typeof OutMode)[];
6
6
  constructor(container: Container);
7
- update(particle: Particle, direction: OutModeDirection, _delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void;
7
+ update(particle: Particle, direction: OutModeDirection, _delta: IDelta, outMode: OutMode | keyof typeof OutMode): Promise<void>;
8
8
  }
@@ -1,10 +1,10 @@
1
- import type { IBounds, ICoordinates, IDimension, OutMode, OutModeAlt, OutModeDirection, Particle } from "@tsparticles/engine";
1
+ import type { IBounds, ICoordinates, IDimension, OutMode, OutModeDirection, Particle } from "@tsparticles/engine";
2
2
  export interface IBounceData {
3
3
  bounds: IBounds;
4
4
  canvasSize: IDimension;
5
5
  direction: OutModeDirection;
6
6
  offset: ICoordinates;
7
- outMode: OutMode | OutModeAlt | keyof typeof OutMode;
7
+ outMode: OutMode | keyof typeof OutMode;
8
8
  particle: Particle;
9
9
  size: number;
10
10
  }
@@ -1,5 +1,5 @@
1
- import type { IDelta, OutMode, OutModeAlt, OutModeDirection, Particle } from "@tsparticles/engine";
1
+ import type { IDelta, OutMode, OutModeDirection, Particle } from "@tsparticles/engine";
2
2
  export interface IOutModeManager {
3
- modes: (OutMode | OutModeAlt | keyof typeof OutMode)[];
4
- update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void;
3
+ modes: (OutMode | keyof typeof OutMode)[];
4
+ update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | keyof typeof OutMode): Promise<void>;
5
5
  }
@@ -1,8 +1,8 @@
1
- import { type Container, type IDelta, OutMode, type OutModeAlt, OutModeDirection, type Particle } from "@tsparticles/engine";
1
+ import { type Container, type IDelta, OutMode, OutModeDirection, type Particle } from "@tsparticles/engine";
2
2
  import type { IOutModeManager } from "./IOutModeManager.js";
3
3
  export declare class NoneOutMode implements IOutModeManager {
4
4
  private readonly container;
5
- modes: (OutMode | OutModeAlt | keyof typeof OutMode)[];
5
+ modes: (OutMode | keyof typeof OutMode)[];
6
6
  constructor(container: Container);
7
- update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void;
7
+ update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | keyof typeof OutMode): Promise<void>;
8
8
  }
@@ -4,8 +4,8 @@ export declare class OutOfCanvasUpdater implements IParticleUpdater {
4
4
  updaters: IOutModeManager[];
5
5
  private readonly container;
6
6
  constructor(container: Container);
7
- init(): void;
7
+ init(particle: Particle): Promise<void>;
8
8
  isEnabled(particle: Particle): boolean;
9
- update(particle: Particle, delta: IDelta): void;
9
+ update(particle: Particle, delta: IDelta): Promise<void>;
10
10
  private readonly _updateOutMode;
11
11
  }
@@ -1,8 +1,8 @@
1
- import { type Container, type IDelta, OutMode, type OutModeAlt, OutModeDirection, type Particle } from "@tsparticles/engine";
1
+ import { type Container, type IDelta, OutMode, OutModeDirection, type Particle } from "@tsparticles/engine";
2
2
  import type { IOutModeManager } from "./IOutModeManager.js";
3
3
  export declare class OutOutMode implements IOutModeManager {
4
4
  private readonly container;
5
- modes: (OutMode | OutModeAlt | keyof typeof OutMode)[];
5
+ modes: (OutMode | keyof typeof OutMode)[];
6
6
  constructor(container: Container);
7
- update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void;
7
+ update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | keyof typeof OutMode): Promise<void>;
8
8
  }
@@ -1,30 +1,49 @@
1
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
+ if (k2 === undefined) k2 = k;
3
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
+ desc = { enumerable: true, get: function() { return m[k]; } };
6
+ }
7
+ Object.defineProperty(o, k2, desc);
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || function (mod) {
18
+ if (mod && mod.__esModule) return mod;
19
+ var result = {};
20
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ __setModuleDefault(result, mod);
22
+ return result;
23
+ };
1
24
  (function (factory) {
2
25
  if (typeof module === "object" && typeof module.exports === "object") {
3
26
  var v = factory(require, exports);
4
27
  if (v !== undefined) module.exports = v;
5
28
  }
6
29
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine", "./Utils.js"], factory);
30
+ define(["require", "exports", "@tsparticles/engine"], factory);
8
31
  }
9
32
  })(function (require, exports) {
10
33
  "use strict";
34
+ var __syncRequire = typeof module === "object" && typeof module.exports === "object";
11
35
  Object.defineProperty(exports, "__esModule", { value: true });
12
36
  exports.BounceOutMode = void 0;
13
37
  const engine_1 = require("@tsparticles/engine");
14
- const Utils_js_1 = require("./Utils.js");
15
38
  class BounceOutMode {
16
39
  constructor(container) {
17
40
  this.container = container;
18
41
  this.modes = [
19
42
  "bounce",
20
- "bounce-vertical",
21
- "bounce-horizontal",
22
- "bounceVertical",
23
- "bounceHorizontal",
24
43
  "split",
25
44
  ];
26
45
  }
27
- update(particle, direction, delta, outMode) {
46
+ async update(particle, direction, delta, outMode) {
28
47
  if (!this.modes.includes(outMode)) {
29
48
  return;
30
49
  }
@@ -32,7 +51,7 @@
32
51
  let handled = false;
33
52
  for (const [, plugin] of container.plugins) {
34
53
  if (plugin.particleBounce !== undefined) {
35
- handled = plugin.particleBounce(particle, delta, direction);
54
+ handled = await plugin.particleBounce(particle, delta, direction);
36
55
  }
37
56
  if (handled) {
38
57
  break;
@@ -41,9 +60,9 @@
41
60
  if (handled) {
42
61
  return;
43
62
  }
44
- const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = (0, engine_1.calculateBounds)(pos, size), canvasSize = container.canvas.size;
45
- (0, Utils_js_1.bounceHorizontal)({ particle, outMode, direction, bounds, canvasSize, offset, size });
46
- (0, Utils_js_1.bounceVertical)({ particle, outMode, direction, bounds, canvasSize, offset, size });
63
+ const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = (0, engine_1.calculateBounds)(pos, size), canvasSize = container.canvas.size, { bounceHorizontal, bounceVertical } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Utils.js"))) : new Promise((resolve_1, reject_1) => { require(["./Utils.js"], resolve_1, reject_1); }).then(__importStar));
64
+ bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, size });
65
+ bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, size });
47
66
  }
48
67
  }
49
68
  exports.BounceOutMode = BounceOutMode;
@@ -17,7 +17,7 @@
17
17
  this.container = container;
18
18
  this.modes = ["destroy"];
19
19
  }
20
- update(particle, direction, _delta, outMode) {
20
+ async update(particle, direction, _delta, outMode) {
21
21
  if (!this.modes.includes(outMode)) {
22
22
  return;
23
23
  }
@@ -30,8 +30,7 @@
30
30
  }
31
31
  break;
32
32
  case "inside": {
33
- const { dx, dy } = (0, engine_1.getDistances)(particle.position, particle.moveCenter);
34
- const { x: vx, y: vy } = particle.velocity;
33
+ const { dx, dy } = (0, engine_1.getDistances)(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity;
35
34
  if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
36
35
  (vy < minVelocity && dy > particle.moveCenter.radius) ||
37
36
  (vx >= minVelocity && dx < -particle.moveCenter.radius) ||
@@ -42,6 +41,7 @@
42
41
  }
43
42
  }
44
43
  container.particles.remove(particle, undefined, true);
44
+ await Promise.resolve();
45
45
  }
46
46
  }
47
47
  exports.DestroyOutMode = DestroyOutMode;
@@ -17,7 +17,7 @@
17
17
  this.container = container;
18
18
  this.modes = ["none"];
19
19
  }
20
- update(particle, direction, delta, outMode) {
20
+ async update(particle, direction, delta, outMode) {
21
21
  if (!this.modes.includes(outMode)) {
22
22
  return;
23
23
  }
@@ -27,9 +27,7 @@
27
27
  (direction === "top" || direction === "bottom"))) {
28
28
  return;
29
29
  }
30
- const gravityOptions = particle.options.move.gravity, container = this.container;
31
- const canvasSize = container.canvas.size;
32
- const pRadius = particle.getRadius();
30
+ const gravityOptions = particle.options.move.gravity, container = this.container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
33
31
  if (!gravityOptions.enable) {
34
32
  if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) ||
35
33
  (particle.velocity.y < minVelocity && particle.position.y >= -pRadius) ||
@@ -50,6 +48,7 @@
50
48
  container.particles.remove(particle);
51
49
  }
52
50
  }
51
+ await Promise.resolve();
53
52
  }
54
53
  }
55
54
  exports.NoneOutMode = NoneOutMode;
@@ -1,45 +1,85 @@
1
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
+ if (k2 === undefined) k2 = k;
3
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
+ desc = { enumerable: true, get: function() { return m[k]; } };
6
+ }
7
+ Object.defineProperty(o, k2, desc);
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || function (mod) {
18
+ if (mod && mod.__esModule) return mod;
19
+ var result = {};
20
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ __setModuleDefault(result, mod);
22
+ return result;
23
+ };
1
24
  (function (factory) {
2
25
  if (typeof module === "object" && typeof module.exports === "object") {
3
26
  var v = factory(require, exports);
4
27
  if (v !== undefined) module.exports = v;
5
28
  }
6
29
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./BounceOutMode.js", "./DestroyOutMode.js", "./NoneOutMode.js", "./OutOutMode.js"], factory);
30
+ define(["require", "exports"], factory);
8
31
  }
9
32
  })(function (require, exports) {
10
33
  "use strict";
34
+ var __syncRequire = typeof module === "object" && typeof module.exports === "object";
11
35
  Object.defineProperty(exports, "__esModule", { value: true });
12
36
  exports.OutOfCanvasUpdater = void 0;
13
- const BounceOutMode_js_1 = require("./BounceOutMode.js");
14
- const DestroyOutMode_js_1 = require("./DestroyOutMode.js");
15
- const NoneOutMode_js_1 = require("./NoneOutMode.js");
16
- const OutOutMode_js_1 = require("./OutOutMode.js");
37
+ const checkOutMode = (outModes, outMode) => {
38
+ return (outModes.default === outMode ||
39
+ outModes.bottom === outMode ||
40
+ outModes.left === outMode ||
41
+ outModes.right === outMode ||
42
+ outModes.top === outMode);
43
+ };
17
44
  class OutOfCanvasUpdater {
18
45
  constructor(container) {
19
- this._updateOutMode = (particle, delta, outMode, direction) => {
46
+ this._updateOutMode = async (particle, delta, outMode, direction) => {
20
47
  for (const updater of this.updaters) {
21
- updater.update(particle, direction, delta, outMode);
48
+ await updater.update(particle, direction, delta, outMode);
22
49
  }
23
50
  };
24
51
  this.container = container;
25
- this.updaters = [
26
- new BounceOutMode_js_1.BounceOutMode(container),
27
- new DestroyOutMode_js_1.DestroyOutMode(container),
28
- new OutOutMode_js_1.OutOutMode(container),
29
- new NoneOutMode_js_1.NoneOutMode(container),
30
- ];
52
+ this.updaters = [];
31
53
  }
32
- init() {
54
+ async init(particle) {
55
+ this.updaters = [];
56
+ const outModes = particle.options.move.outModes;
57
+ if (checkOutMode(outModes, "bounce")) {
58
+ const { BounceOutMode } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./BounceOutMode.js"))) : new Promise((resolve_1, reject_1) => { require(["./BounceOutMode.js"], resolve_1, reject_1); }).then(__importStar));
59
+ this.updaters.push(new BounceOutMode(this.container));
60
+ }
61
+ else if (checkOutMode(outModes, "out")) {
62
+ const { OutOutMode } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./OutOutMode.js"))) : new Promise((resolve_2, reject_2) => { require(["./OutOutMode.js"], resolve_2, reject_2); }).then(__importStar));
63
+ this.updaters.push(new OutOutMode(this.container));
64
+ }
65
+ else if (checkOutMode(outModes, "destroy")) {
66
+ const { DestroyOutMode } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./DestroyOutMode.js"))) : new Promise((resolve_3, reject_3) => { require(["./DestroyOutMode.js"], resolve_3, reject_3); }).then(__importStar));
67
+ this.updaters.push(new DestroyOutMode(this.container));
68
+ }
69
+ else if (checkOutMode(outModes, "none")) {
70
+ const { NoneOutMode } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./NoneOutMode.js"))) : new Promise((resolve_4, reject_4) => { require(["./NoneOutMode.js"], resolve_4, reject_4); }).then(__importStar));
71
+ this.updaters.push(new NoneOutMode(this.container));
72
+ }
33
73
  }
34
74
  isEnabled(particle) {
35
75
  return !particle.destroyed && !particle.spawning;
36
76
  }
37
- update(particle, delta) {
77
+ async update(particle, delta) {
38
78
  const outModes = particle.options.move.outModes;
39
- this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom");
40
- this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left");
41
- this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right");
42
- this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top");
79
+ await this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom");
80
+ await this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left");
81
+ await this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right");
82
+ await this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top");
43
83
  }
44
84
  }
45
85
  exports.OutOfCanvasUpdater = OutOfCanvasUpdater;
package/umd/OutOutMode.js CHANGED
@@ -17,7 +17,7 @@
17
17
  this.container = container;
18
18
  this.modes = ["out"];
19
19
  }
20
- update(particle, direction, delta, outMode) {
20
+ async update(particle, direction, delta, outMode) {
21
21
  if (!this.modes.includes(outMode)) {
22
22
  return;
23
23
  }
@@ -119,6 +119,7 @@
119
119
  break;
120
120
  }
121
121
  }
122
+ await Promise.resolve();
122
123
  }
123
124
  }
124
125
  exports.OutOutMode = OutOutMode;
package/umd/Utils.js CHANGED
@@ -13,10 +13,7 @@
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  const minVelocity = 0, boundsMin = 0;
15
15
  function bounceHorizontal(data) {
16
- if ((data.outMode !== "bounce" &&
17
- data.outMode !== "bounce-horizontal" &&
18
- data.outMode !== "bounceHorizontal" &&
19
- data.outMode !== "split") ||
16
+ if ((data.outMode !== "bounce" && data.outMode !== "split") ||
20
17
  (data.direction !== "left" && data.direction !== "right")) {
21
18
  return;
22
19
  }
@@ -52,10 +49,7 @@
52
49
  }
53
50
  exports.bounceHorizontal = bounceHorizontal;
54
51
  function bounceVertical(data) {
55
- if ((data.outMode !== "bounce" &&
56
- data.outMode !== "bounce-vertical" &&
57
- data.outMode !== "bounceVertical" &&
58
- data.outMode !== "split") ||
52
+ if ((data.outMode !== "bounce" && data.outMode !== "split") ||
59
53
  (data.direction !== "bottom" && data.direction !== "top")) {
60
54
  return;
61
55
  }
package/umd/index.js CHANGED
@@ -1,18 +1,44 @@
1
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
+ if (k2 === undefined) k2 = k;
3
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
+ desc = { enumerable: true, get: function() { return m[k]; } };
6
+ }
7
+ Object.defineProperty(o, k2, desc);
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || function (mod) {
18
+ if (mod && mod.__esModule) return mod;
19
+ var result = {};
20
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ __setModuleDefault(result, mod);
22
+ return result;
23
+ };
1
24
  (function (factory) {
2
25
  if (typeof module === "object" && typeof module.exports === "object") {
3
26
  var v = factory(require, exports);
4
27
  if (v !== undefined) module.exports = v;
5
28
  }
6
29
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./OutOfCanvasUpdater.js"], factory);
30
+ define(["require", "exports"], factory);
8
31
  }
9
32
  })(function (require, exports) {
10
33
  "use strict";
34
+ var __syncRequire = typeof module === "object" && typeof module.exports === "object";
11
35
  Object.defineProperty(exports, "__esModule", { value: true });
12
36
  exports.loadOutModesUpdater = void 0;
13
- const OutOfCanvasUpdater_js_1 = require("./OutOfCanvasUpdater.js");
14
37
  async function loadOutModesUpdater(engine, refresh = true) {
15
- await engine.addParticleUpdater("outModes", (container) => new OutOfCanvasUpdater_js_1.OutOfCanvasUpdater(container), refresh);
38
+ await engine.addParticleUpdater("outModes", async (container) => {
39
+ const { OutOfCanvasUpdater } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./OutOfCanvasUpdater.js"))) : new Promise((resolve_1, reject_1) => { require(["./OutOfCanvasUpdater.js"], resolve_1, reject_1); }).then(__importStar));
40
+ return new OutOfCanvasUpdater(container);
41
+ }, refresh);
16
42
  }
17
43
  exports.loadOutModesUpdater = loadOutModesUpdater;
18
44
  });