Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tsparticles-updater-out-modes

Package Overview
Dependencies
Maintainers
2
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsparticles-updater-out-modes - npm Package Compare versions

Comparing version 2.10.1 to 2.11.0

4

browser/index.js
import { OutOfCanvasUpdater } from "./OutOfCanvasUpdater";
export async function loadOutModesUpdater(engine) {
await engine.addParticleUpdater("outModes", (container) => new OutOfCanvasUpdater(container));
export async function loadOutModesUpdater(engine, refresh = true) {
await engine.addParticleUpdater("outModes", (container) => new OutOfCanvasUpdater(container), refresh);
}

@@ -5,5 +5,5 @@ "use strict";

const OutOfCanvasUpdater_1 = require("./OutOfCanvasUpdater");
async function loadOutModesUpdater(engine) {
await engine.addParticleUpdater("outModes", (container) => new OutOfCanvasUpdater_1.OutOfCanvasUpdater(container));
async function loadOutModesUpdater(engine, refresh = true) {
await engine.addParticleUpdater("outModes", (container) => new OutOfCanvasUpdater_1.OutOfCanvasUpdater(container), refresh);
}
exports.loadOutModesUpdater = loadOutModesUpdater;
import { OutOfCanvasUpdater } from "./OutOfCanvasUpdater";
export async function loadOutModesUpdater(engine) {
await engine.addParticleUpdater("outModes", (container) => new OutOfCanvasUpdater(container));
export async function loadOutModesUpdater(engine, refresh = true) {
await engine.addParticleUpdater("outModes", (container) => new OutOfCanvasUpdater(container), refresh);
}
{
"name": "tsparticles-updater-out-modes",
"version": "2.10.1",
"version": "2.11.0",
"description": "tsParticles particles out modes updater",

@@ -76,5 +76,6 @@ "homepage": "https://particles.js.org",

"types": "types/index.d.ts",
"sideEffects": false,
"dependencies": {
"tsparticles-engine": "^2.10.1"
"tsparticles-engine": "^2.11.0"
}
}

@@ -28,7 +28,12 @@ [![banner](https://particles.js.org/images/banner2.png)](https://particles.js.org)

```javascript
loadOutModesUpdater(tsParticles);
(async () => {
await loadOutModesUpdater(tsParticles);
tsParticles.load("tsparticles", {
/* options */
});
await tsParticles.load({
id: "tsparticles",
options: {
/* options */
},
});
})();
```

@@ -56,3 +61,5 @@

loadOutModesUpdater(tsParticles);
(async () => {
await loadOutModesUpdater(tsParticles);
})();
```

@@ -66,3 +73,5 @@

loadOutModesUpdater(tsParticles);
(async () => {
await loadOutModesUpdater(tsParticles);
})();
```

@@ -7,3 +7,3 @@ /*!

* How to use? : Check the GitHub README
* v2.10.1
* v2.11.0
*/

@@ -432,4 +432,4 @@ (function webpackUniversalModuleDefinition(root, factory) {

async function loadOutModesUpdater(engine) {
await engine.addParticleUpdater("outModes", container => new OutOfCanvasUpdater(container));
async function loadOutModesUpdater(engine, refresh = true) {
await engine.addParticleUpdater("outModes", container => new OutOfCanvasUpdater(container), refresh);
}

@@ -436,0 +436,0 @@ })();

/*! For license information please see tsparticles.updater.out-modes.min.js.LICENSE.txt */
!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={961: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(961);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 a=!1;for(const[,t]of s.plugins)if(void 0!==t.particleBounce&&(a=t.particleBounce(e,i,o)),a)break;if(a)return;const r=e.getPosition(),c=e.offset,d=e.getRadius(),u=(0,t.calculateBounds)(r,d),p=s.canvas.size;!function(e){if("bounce"!==e.outMode&&"bounce-horizontal"!==e.outMode&&"bounceHorizontal"!==e.outMode&&"split"!==e.outMode)return;e.bounds.right<0?e.particle.position.x=e.size+e.offset.x:e.bounds.left>e.canvasSize.width&&(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.getValue)(e.particle.options.bounce.horizontal);e.particle.velocity.x*=-o,i=!0}if(!i)return;const n=e.offset.x+e.size;e.bounds.right>=e.canvasSize.width?e.particle.position.x=e.canvasSize.width-n:e.bounds.left<=0&&(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)return;e.bounds.bottom<0?e.particle.position.y=e.size+e.offset.y:e.bounds.top>e.canvasSize.height&&(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.getValue)(e.particle.options.bounce.vertical);e.particle.velocity.y*=-o,i=!0}if(!i)return;const n=e.offset.y+e.size;e.bounds.bottom>=e.canvasSize.height?e.particle.position.y=e.canvasSize.height-n:e.bounds.top<=0&&(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,a=this.container,r=a.canvas.size,c=e.getRadius();if(s.enable){const t=e.position;(!s.inverse&&t.y>r.height+c&&"bottom"===o||s.inverse&&t.y<-c&&"top"===o)&&a.particles.remove(e)}else{if(e.velocity.y>0&&e.position.y<=r.height+c||e.velocity.y<0&&e.position.y>=-c||e.velocity.x>0&&e.position.x<=r.width+c||e.velocity.x<0&&e.position.x>=-c)return;(0,t.isPointInside)(e.position,a.canvas.size,t.Vector.origin,c,o)||a.particles.remove(e)}}}class a{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:a,dy:r}=(0,t.getDistances)(e.position,n);if(o<=0&&a>=0||i<=0&&r>=0||o>=0&&a<=0||i>=0&&r<=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,a={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},r=e.getRadius(),c=(0,t.calculateBounds)(e.position,r);"right"===o&&c.left>n.width+e.offset.x?(e.position.x=a.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=a.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=a.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=a.bottom,e.initialPosition.y=e.position.y);break}}}}}class r{constructor(t){this.container=t,this._updateOutMode=(t,e,o,i)=>{for(const n of this.updaters)n.update(t,i,e,o)},this.updaters=[new e(t),new o(t),new a(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){await t.addParticleUpdater("outModes",(t=>new r(t)))}})(),n})()));
!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={961: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(961);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 a=!1;for(const[,t]of s.plugins)if(void 0!==t.particleBounce&&(a=t.particleBounce(e,i,o)),a)break;if(a)return;const r=e.getPosition(),c=e.offset,d=e.getRadius(),u=(0,t.calculateBounds)(r,d),p=s.canvas.size;!function(e){if("bounce"!==e.outMode&&"bounce-horizontal"!==e.outMode&&"bounceHorizontal"!==e.outMode&&"split"!==e.outMode)return;e.bounds.right<0?e.particle.position.x=e.size+e.offset.x:e.bounds.left>e.canvasSize.width&&(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.getValue)(e.particle.options.bounce.horizontal);e.particle.velocity.x*=-o,i=!0}if(!i)return;const n=e.offset.x+e.size;e.bounds.right>=e.canvasSize.width?e.particle.position.x=e.canvasSize.width-n:e.bounds.left<=0&&(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)return;e.bounds.bottom<0?e.particle.position.y=e.size+e.offset.y:e.bounds.top>e.canvasSize.height&&(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.getValue)(e.particle.options.bounce.vertical);e.particle.velocity.y*=-o,i=!0}if(!i)return;const n=e.offset.y+e.size;e.bounds.bottom>=e.canvasSize.height?e.particle.position.y=e.canvasSize.height-n:e.bounds.top<=0&&(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,a=this.container,r=a.canvas.size,c=e.getRadius();if(s.enable){const t=e.position;(!s.inverse&&t.y>r.height+c&&"bottom"===o||s.inverse&&t.y<-c&&"top"===o)&&a.particles.remove(e)}else{if(e.velocity.y>0&&e.position.y<=r.height+c||e.velocity.y<0&&e.position.y>=-c||e.velocity.x>0&&e.position.x<=r.width+c||e.velocity.x<0&&e.position.x>=-c)return;(0,t.isPointInside)(e.position,a.canvas.size,t.Vector.origin,c,o)||a.particles.remove(e)}}}class a{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:a,dy:r}=(0,t.getDistances)(e.position,n);if(o<=0&&a>=0||i<=0&&r>=0||o>=0&&a<=0||i>=0&&r<=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,a={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},r=e.getRadius(),c=(0,t.calculateBounds)(e.position,r);"right"===o&&c.left>n.width+e.offset.x?(e.position.x=a.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=a.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=a.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=a.bottom,e.initialPosition.y=e.position.y);break}}}}}class r{constructor(t){this.container=t,this._updateOutMode=(t,e,o,i)=>{for(const n of this.updaters)n.update(t,i,e,o)},this.updaters=[new e(t),new o(t),new a(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 r(t)),e)}})(),n})()));

@@ -1,1 +0,1 @@

/*! tsParticles Out Modes Updater v2.10.1 by Matteo Bruni */
/*! tsParticles Out Modes Updater v2.11.0 by Matteo Bruni */
import type { Engine } from "tsparticles-engine";
export declare function loadOutModesUpdater(engine: Engine): Promise<void>;
export declare function loadOutModesUpdater(engine: Engine, refresh?: boolean): Promise<void>;

@@ -14,6 +14,6 @@ (function (factory) {

const OutOfCanvasUpdater_1 = require("./OutOfCanvasUpdater");
async function loadOutModesUpdater(engine) {
await engine.addParticleUpdater("outModes", (container) => new OutOfCanvasUpdater_1.OutOfCanvasUpdater(container));
async function loadOutModesUpdater(engine, refresh = true) {
await engine.addParticleUpdater("outModes", (container) => new OutOfCanvasUpdater_1.OutOfCanvasUpdater(container), refresh);
}
exports.loadOutModesUpdater = loadOutModesUpdater;
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc