Socket
Socket
Sign inDemoInstall

@tsparticles/updater-out-modes

Package Overview
Dependencies
Maintainers
0
Versions
19
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 3.4.0 to 3.5.0

3

cjs/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadOutModesUpdater = void 0;
exports.loadOutModesUpdater = loadOutModesUpdater;
const OutOfCanvasUpdater_js_1 = require("./OutOfCanvasUpdater.js");

@@ -10,2 +10,1 @@ async function loadOutModesUpdater(engine, refresh = true) {

}
exports.loadOutModesUpdater = loadOutModesUpdater;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bounceVertical = exports.bounceHorizontal = void 0;
exports.bounceHorizontal = bounceHorizontal;
exports.bounceVertical = bounceVertical;
const engine_1 = require("@tsparticles/engine");

@@ -41,3 +42,2 @@ const minVelocity = 0, boundsMin = 0;

}
exports.bounceHorizontal = bounceHorizontal;
function bounceVertical(data) {

@@ -78,2 +78,1 @@ if ((data.outMode !== engine_1.OutMode.bounce && data.outMode !== engine_1.OutMode.split) ||

}
exports.bounceVertical = bounceVertical;
{
"name": "@tsparticles/updater-out-modes",
"version": "3.4.0",
"version": "3.5.0",
"description": "tsParticles particles out modes updater",

@@ -90,3 +90,3 @@ "homepage": "https://particles.js.org",

"dependencies": {
"@tsparticles/engine": "^3.4.0"
"@tsparticles/engine": "^3.5.0"
},

@@ -93,0 +93,0 @@ "publishConfig": {

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

* How to use? : Check the GitHub README
* v3.4.0
* v3.5.0
*/

@@ -10,0 +10,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=>(()=>{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})()));
!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 +0,1 @@

/*! tsParticles Out Modes Updater v3.4.0 by Matteo Bruni */
/*! tsParticles Out Modes Updater v3.5.0 by Matteo Bruni */

@@ -12,3 +12,3 @@ (function (factory) {

Object.defineProperty(exports, "__esModule", { value: true });
exports.loadOutModesUpdater = void 0;
exports.loadOutModesUpdater = loadOutModesUpdater;
const OutOfCanvasUpdater_js_1 = require("./OutOfCanvasUpdater.js");

@@ -20,3 +20,2 @@ async function loadOutModesUpdater(engine, refresh = true) {

}
exports.loadOutModesUpdater = loadOutModesUpdater;
});

@@ -12,3 +12,4 @@ (function (factory) {

Object.defineProperty(exports, "__esModule", { value: true });
exports.bounceVertical = exports.bounceHorizontal = void 0;
exports.bounceHorizontal = bounceHorizontal;
exports.bounceVertical = bounceVertical;
const engine_1 = require("@tsparticles/engine");

@@ -51,3 +52,2 @@ const minVelocity = 0, boundsMin = 0;

}
exports.bounceHorizontal = bounceHorizontal;
function bounceVertical(data) {

@@ -88,3 +88,2 @@ if ((data.outMode !== engine_1.OutMode.bounce && data.outMode !== engine_1.OutMode.split) ||

}
exports.bounceVertical = bounceVertical;
});

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