@tsparticles/updater-out-modes 3.4.0 → 3.5.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.
package/cjs/Utils.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bounceVertical = exports.bounceHorizontal = void 0;
3
+ exports.bounceHorizontal = bounceHorizontal;
4
+ exports.bounceVertical = bounceVertical;
4
5
  const engine_1 = require("@tsparticles/engine");
5
6
  const minVelocity = 0, boundsMin = 0;
6
7
  function bounceHorizontal(data) {
@@ -38,7 +39,6 @@ function bounceHorizontal(data) {
38
39
  data.particle.destroy();
39
40
  }
40
41
  }
41
- exports.bounceHorizontal = bounceHorizontal;
42
42
  function bounceVertical(data) {
43
43
  if ((data.outMode !== engine_1.OutMode.bounce && data.outMode !== engine_1.OutMode.split) ||
44
44
  (data.direction !== engine_1.OutModeDirection.bottom && data.direction !== engine_1.OutModeDirection.top)) {
@@ -74,4 +74,3 @@ function bounceVertical(data) {
74
74
  data.particle.destroy();
75
75
  }
76
76
  }
77
- exports.bounceVertical = bounceVertical;
package/cjs/index.js CHANGED
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadOutModesUpdater = void 0;
3
+ exports.loadOutModesUpdater = loadOutModesUpdater;
4
4
  const OutOfCanvasUpdater_js_1 = require("./OutOfCanvasUpdater.js");
5
5
  async function loadOutModesUpdater(engine, refresh = true) {
6
6
  await engine.addParticleUpdater("outModes", container => {
7
7
  return Promise.resolve(new OutOfCanvasUpdater_js_1.OutOfCanvasUpdater(container));
8
8
  }, refresh);
9
9
  }
10
- exports.loadOutModesUpdater = loadOutModesUpdater;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/updater-out-modes",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "description": "tsParticles particles out modes updater",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -87,7 +87,7 @@
87
87
  "./package.json": "./package.json"
88
88
  },
89
89
  "dependencies": {
90
- "@tsparticles/engine": "^3.4.0"
90
+ "@tsparticles/engine": "^3.5.0"
91
91
  },
92
92
  "publishConfig": {
93
93
  "access": "public"
package/report.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8"/>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
- <title>@tsparticles/updater-out-modes [13 May 2024 at 00:14]</title>
6
+ <title>@tsparticles/updater-out-modes [1 Jul 2024 at 09:24]</title>
7
7
  <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
8
8
 
9
9
  <script>
@@ -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.4.0
7
+ * v3.5.0
8
8
  */
9
9
  /*
10
10
  * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
@@ -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=>(()=>{var e={303: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:()=>d});var t=i(303);class e{constructor(e){this.container=e,this.modes=[t.OutMode.bounce,t.OutMode.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(e.outMode!==t.OutMode.bounce&&e.outMode!==t.OutMode.split||e.direction!==t.OutModeDirection.left&&e.direction!==t.OutModeDirection.right)return;e.bounds.right<0&&e.direction===t.OutModeDirection.left?e.particle.position.x=e.size+e.offset.x:e.bounds.left>e.canvasSize.width&&e.direction===t.OutModeDirection.right&&(e.particle.position.x=e.canvasSize.width-e.size-e.offset.x);const o=e.particle.velocity.x;let i=!1;if(e.direction===t.OutModeDirection.right&&e.bounds.right>=e.canvasSize.width&&o>0||e.direction===t.OutModeDirection.left&&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&&e.direction===t.OutModeDirection.right?e.particle.position.x=e.canvasSize.width-n:e.bounds.left<=0&&e.direction===t.OutModeDirection.left&&(e.particle.position.x=n),e.outMode===t.OutMode.split&&e.particle.destroy()}({particle:e,outMode:n,direction:o,bounds:u,canvasSize:p,offset:c,size:d}),function(e){if(e.outMode!==t.OutMode.bounce&&e.outMode!==t.OutMode.split||e.direction!==t.OutModeDirection.bottom&&e.direction!==t.OutModeDirection.top)return;e.bounds.bottom<0&&e.direction===t.OutModeDirection.top?e.particle.position.y=e.size+e.offset.y:e.bounds.top>e.canvasSize.height&&e.direction===t.OutModeDirection.bottom&&(e.particle.position.y=e.canvasSize.height-e.size-e.offset.y);const o=e.particle.velocity.y;let i=!1;if(e.direction===t.OutModeDirection.bottom&&e.bounds.bottom>=e.canvasSize.height&&o>0||e.direction===t.OutModeDirection.top&&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&&e.direction===t.OutModeDirection.bottom?e.particle.position.y=e.canvasSize.height-n:e.bounds.top<=0&&e.direction===t.OutModeDirection.top&&(e.particle.position.y=n),e.outMode===t.OutMode.split&&e.particle.destroy()}({particle:e,outMode:n,direction:o,bounds:u,canvasSize:p,offset:c,size:d})}}class o{constructor(e){this.container=e,this.modes=[t.OutMode.destroy]}update(e,o,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(e.outType){case t.ParticleOutType.normal:case t.ParticleOutType.outside:if((0,t.isPointInside)(e.position,s.canvas.size,t.Vector.origin,e.getRadius(),o))return;break;case t.ParticleOutType.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(e){this.container=e,this.modes=[t.OutMode.none]}update(e,o,i,n){if(!this.modes.includes(n))return;if((e.options.move.distance.horizontal&&(o===t.OutModeDirection.left||o===t.OutModeDirection.right))??(e.options.move.distance.vertical&&(o===t.OutModeDirection.top||o===t.OutModeDirection.bottom)))return;const s=e.options.move.gravity,r=this.container,a=r.canvas.size,c=e.getRadius();if(s.enable){const i=e.position;(!s.inverse&&i.y>a.height+c&&o===t.OutModeDirection.bottom||s.inverse&&i.y<-c&&o===t.OutModeDirection.top)&&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(e){this.container=e,this.modes=[t.OutMode.out]}update(e,o,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(e.outType){case t.ParticleOutType.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 t.ParticleOutType.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 t.ParticleOutType.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);o===t.OutModeDirection.right&&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)):o===t.OutModeDirection.left&&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)),o===t.OutModeDirection.bottom&&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):o===t.OutModeDirection.top&&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}}}}}const a=(t,e)=>t.default===e||t.bottom===e||t.left===e||t.right===e||t.top===e;class c{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=[]}init(i){this.updaters=[];const n=i.options.move.outModes;a(n,t.OutMode.bounce)?this.updaters.push(new e(this.container)):a(n,t.OutMode.out)?this.updaters.push(new r(this.container)):a(n,t.OutMode.destroy)?this.updaters.push(new o(this.container)):a(n,t.OutMode.none)&&this.updaters.push(new s(this.container))}isEnabled(t){return!t.destroyed&&!t.spawning}update(e,o){const i=e.options.move.outModes;this._updateOutMode(e,o,i.bottom??i.default,t.OutModeDirection.bottom),this._updateOutMode(e,o,i.left??i.default,t.OutModeDirection.left),this._updateOutMode(e,o,i.right??i.default,t.OutModeDirection.right),this._updateOutMode(e,o,i.top??i.default,t.OutModeDirection.top)}}async function d(t,e=!0){await t.addParticleUpdater("outModes",(t=>Promise.resolve(new c(t))),e)}})(),n})()));
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=>(()=>{var e={303: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={};i.r(n),i.d(n,{loadOutModesUpdater:()=>l});var s=i(303);class r{constructor(t){this.container=t,this.modes=[s.OutMode.bounce,s.OutMode.split]}update(t,e,o,i){if(!this.modes.includes(i))return;const n=this.container;let r=!1;for(const[,i]of n.plugins)if(void 0!==i.particleBounce&&(r=i.particleBounce(t,o,e)),r)break;if(r)return;const a=t.getPosition(),c=t.offset,d=t.getRadius(),u=(0,s.calculateBounds)(a,d),p=n.canvas.size;!function(t){if(t.outMode!==s.OutMode.bounce&&t.outMode!==s.OutMode.split||t.direction!==s.OutModeDirection.left&&t.direction!==s.OutModeDirection.right)return;t.bounds.right<0&&t.direction===s.OutModeDirection.left?t.particle.position.x=t.size+t.offset.x:t.bounds.left>t.canvasSize.width&&t.direction===s.OutModeDirection.right&&(t.particle.position.x=t.canvasSize.width-t.size-t.offset.x);const e=t.particle.velocity.x;let o=!1;if(t.direction===s.OutModeDirection.right&&t.bounds.right>=t.canvasSize.width&&e>0||t.direction===s.OutModeDirection.left&&t.bounds.left<=0&&e<0){const e=(0,s.getRangeValue)(t.particle.options.bounce.horizontal.value);t.particle.velocity.x*=-e,o=!0}if(!o)return;const i=t.offset.x+t.size;t.bounds.right>=t.canvasSize.width&&t.direction===s.OutModeDirection.right?t.particle.position.x=t.canvasSize.width-i:t.bounds.left<=0&&t.direction===s.OutModeDirection.left&&(t.particle.position.x=i),t.outMode===s.OutMode.split&&t.particle.destroy()}({particle:t,outMode:i,direction:e,bounds:u,canvasSize:p,offset:c,size:d}),function(t){if(t.outMode!==s.OutMode.bounce&&t.outMode!==s.OutMode.split||t.direction!==s.OutModeDirection.bottom&&t.direction!==s.OutModeDirection.top)return;t.bounds.bottom<0&&t.direction===s.OutModeDirection.top?t.particle.position.y=t.size+t.offset.y:t.bounds.top>t.canvasSize.height&&t.direction===s.OutModeDirection.bottom&&(t.particle.position.y=t.canvasSize.height-t.size-t.offset.y);const e=t.particle.velocity.y;let o=!1;if(t.direction===s.OutModeDirection.bottom&&t.bounds.bottom>=t.canvasSize.height&&e>0||t.direction===s.OutModeDirection.top&&t.bounds.top<=0&&e<0){const e=(0,s.getRangeValue)(t.particle.options.bounce.vertical.value);t.particle.velocity.y*=-e,o=!0}if(!o)return;const i=t.offset.y+t.size;t.bounds.bottom>=t.canvasSize.height&&t.direction===s.OutModeDirection.bottom?t.particle.position.y=t.canvasSize.height-i:t.bounds.top<=0&&t.direction===s.OutModeDirection.top&&(t.particle.position.y=i),t.outMode===s.OutMode.split&&t.particle.destroy()}({particle:t,outMode:i,direction:e,bounds:u,canvasSize:p,offset:c,size:d})}}class a{constructor(t){this.container=t,this.modes=[s.OutMode.destroy]}update(t,e,o,i){if(!this.modes.includes(i))return;const n=this.container;switch(t.outType){case s.ParticleOutType.normal:case s.ParticleOutType.outside:if((0,s.isPointInside)(t.position,n.canvas.size,s.Vector.origin,t.getRadius(),e))return;break;case s.ParticleOutType.inside:{const{dx:e,dy:o}=(0,s.getDistances)(t.position,t.moveCenter),{x:i,y:n}=t.velocity;if(i<0&&e>t.moveCenter.radius||n<0&&o>t.moveCenter.radius||i>=0&&e<-t.moveCenter.radius||n>=0&&o<-t.moveCenter.radius)return;break}}n.particles.remove(t,void 0,!0)}}class c{constructor(t){this.container=t,this.modes=[s.OutMode.none]}update(t,e,o,i){if(!this.modes.includes(i))return;if((t.options.move.distance.horizontal&&(e===s.OutModeDirection.left||e===s.OutModeDirection.right))??(t.options.move.distance.vertical&&(e===s.OutModeDirection.top||e===s.OutModeDirection.bottom)))return;const n=t.options.move.gravity,r=this.container,a=r.canvas.size,c=t.getRadius();if(n.enable){const o=t.position;(!n.inverse&&o.y>a.height+c&&e===s.OutModeDirection.bottom||n.inverse&&o.y<-c&&e===s.OutModeDirection.top)&&r.particles.remove(t)}else{if(t.velocity.y>0&&t.position.y<=a.height+c||t.velocity.y<0&&t.position.y>=-c||t.velocity.x>0&&t.position.x<=a.width+c||t.velocity.x<0&&t.position.x>=-c)return;(0,s.isPointInside)(t.position,r.canvas.size,s.Vector.origin,c,e)||r.particles.remove(t)}}}class d{constructor(t){this.container=t,this.modes=[s.OutMode.out]}update(t,e,o,i){if(!this.modes.includes(i))return;const n=this.container;switch(t.outType){case s.ParticleOutType.inside:{const{x:e,y:o}=t.velocity,i=s.Vector.origin;i.length=t.moveCenter.radius,i.angle=t.velocity.angle+Math.PI,i.addTo(s.Vector.create(t.moveCenter));const{dx:r,dy:a}=(0,s.getDistances)(t.position,i);if(e<=0&&r>=0||o<=0&&a>=0||e>=0&&r<=0||o>=0&&a<=0)return;t.position.x=Math.floor((0,s.randomInRange)({min:0,max:n.canvas.size.width})),t.position.y=Math.floor((0,s.randomInRange)({min:0,max:n.canvas.size.height}));const{dx:c,dy:d}=(0,s.getDistances)(t.position,t.moveCenter);t.direction=Math.atan2(-d,-c),t.velocity.angle=t.direction;break}default:if((0,s.isPointInside)(t.position,n.canvas.size,s.Vector.origin,t.getRadius(),e))return;switch(t.outType){case s.ParticleOutType.outside:{t.position.x=Math.floor((0,s.randomInRange)({min:-t.moveCenter.radius,max:t.moveCenter.radius}))+t.moveCenter.x,t.position.y=Math.floor((0,s.randomInRange)({min:-t.moveCenter.radius,max:t.moveCenter.radius}))+t.moveCenter.y;const{dx:e,dy:o}=(0,s.getDistances)(t.position,t.moveCenter);t.moveCenter.radius&&(t.direction=Math.atan2(o,e),t.velocity.angle=t.direction);break}case s.ParticleOutType.normal:{const o=t.options.move.warp,i=n.canvas.size,r={bottom:i.height+t.getRadius()+t.offset.y,left:-t.getRadius()-t.offset.x,right:i.width+t.getRadius()+t.offset.x,top:-t.getRadius()-t.offset.y},a=t.getRadius(),c=(0,s.calculateBounds)(t.position,a);e===s.OutModeDirection.right&&c.left>i.width+t.offset.x?(t.position.x=r.left,t.initialPosition.x=t.position.x,o||(t.position.y=(0,s.getRandom)()*i.height,t.initialPosition.y=t.position.y)):e===s.OutModeDirection.left&&c.right<-t.offset.x&&(t.position.x=r.right,t.initialPosition.x=t.position.x,o||(t.position.y=(0,s.getRandom)()*i.height,t.initialPosition.y=t.position.y)),e===s.OutModeDirection.bottom&&c.top>i.height+t.offset.y?(o||(t.position.x=(0,s.getRandom)()*i.width,t.initialPosition.x=t.position.x),t.position.y=r.top,t.initialPosition.y=t.position.y):e===s.OutModeDirection.top&&c.bottom<-t.offset.y&&(o||(t.position.x=(0,s.getRandom)()*i.width,t.initialPosition.x=t.position.x),t.position.y=r.bottom,t.initialPosition.y=t.position.y);break}}}}}const u=(t,e)=>t.default===e||t.bottom===e||t.left===e||t.right===e||t.top===e;class p{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=[]}init(t){this.updaters=[];const e=t.options.move.outModes;u(e,s.OutMode.bounce)?this.updaters.push(new r(this.container)):u(e,s.OutMode.out)?this.updaters.push(new d(this.container)):u(e,s.OutMode.destroy)?this.updaters.push(new a(this.container)):u(e,s.OutMode.none)&&this.updaters.push(new c(this.container))}isEnabled(t){return!t.destroyed&&!t.spawning}update(t,e){const o=t.options.move.outModes;this._updateOutMode(t,e,o.bottom??o.default,s.OutModeDirection.bottom),this._updateOutMode(t,e,o.left??o.default,s.OutModeDirection.left),this._updateOutMode(t,e,o.right??o.default,s.OutModeDirection.right),this._updateOutMode(t,e,o.top??o.default,s.OutModeDirection.top)}}async function l(t,e=!0){await t.addParticleUpdater("outModes",(t=>Promise.resolve(new p(t))),e)}return n})()));
@@ -1 +1 @@
1
- /*! tsParticles Out Modes Updater v3.4.0 by Matteo Bruni */
1
+ /*! tsParticles Out Modes Updater v3.5.0 by Matteo Bruni */
package/umd/Utils.js CHANGED
@@ -9,7 +9,8 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.bounceVertical = exports.bounceHorizontal = void 0;
12
+ exports.bounceHorizontal = bounceHorizontal;
13
+ exports.bounceVertical = bounceVertical;
13
14
  const engine_1 = require("@tsparticles/engine");
14
15
  const minVelocity = 0, boundsMin = 0;
15
16
  function bounceHorizontal(data) {
@@ -47,7 +48,6 @@
47
48
  data.particle.destroy();
48
49
  }
49
50
  }
50
- exports.bounceHorizontal = bounceHorizontal;
51
51
  function bounceVertical(data) {
52
52
  if ((data.outMode !== engine_1.OutMode.bounce && data.outMode !== engine_1.OutMode.split) ||
53
53
  (data.direction !== engine_1.OutModeDirection.bottom && data.direction !== engine_1.OutModeDirection.top)) {
@@ -83,5 +83,4 @@
83
83
  data.particle.destroy();
84
84
  }
85
85
  }
86
- exports.bounceVertical = bounceVertical;
87
86
  });
package/umd/index.js CHANGED
@@ -9,12 +9,11 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.loadOutModesUpdater = void 0;
12
+ exports.loadOutModesUpdater = loadOutModesUpdater;
13
13
  const OutOfCanvasUpdater_js_1 = require("./OutOfCanvasUpdater.js");
14
14
  async function loadOutModesUpdater(engine, refresh = true) {
15
15
  await engine.addParticleUpdater("outModes", container => {
16
16
  return Promise.resolve(new OutOfCanvasUpdater_js_1.OutOfCanvasUpdater(container));
17
17
  }, refresh);
18
18
  }
19
- exports.loadOutModesUpdater = loadOutModesUpdater;
20
19
  });