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
21
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.0.3 to 3.1.0

9

browser/DestroyOutMode.js
import { Vector, getDistances, isPointInside, } from "@tsparticles/engine";
const minVelocity = 0;
export class DestroyOutMode {

@@ -22,6 +23,6 @@ constructor(container) {

const { x: vx, y: vy } = particle.velocity;
if ((vx < 0 && dx > particle.moveCenter.radius) ||
(vy < 0 && dy > particle.moveCenter.radius) ||
(vx >= 0 && dx < -particle.moveCenter.radius) ||
(vy >= 0 && dy < -particle.moveCenter.radius)) {
if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
(vy < minVelocity && dy > particle.moveCenter.radius) ||
(vx >= minVelocity && dx < -particle.moveCenter.radius) ||
(vy >= minVelocity && dy < -particle.moveCenter.radius)) {
return;

@@ -28,0 +29,0 @@ }

import { Vector, isPointInside, } from "@tsparticles/engine";
const minVelocity = 0;
export class NoneOutMode {

@@ -12,3 +13,3 @@ constructor(container) {

if ((particle.options.move.distance.horizontal &&
(direction === "left" || direction === "right")) ||
(direction === "left" || direction === "right")) ??
(particle.options.move.distance.vertical &&

@@ -22,6 +23,6 @@ (direction === "top" || direction === "bottom"))) {

if (!gravityOptions.enable) {
if ((particle.velocity.y > 0 && particle.position.y <= canvasSize.height + pRadius) ||
(particle.velocity.y < 0 && particle.position.y >= -pRadius) ||
(particle.velocity.x > 0 && particle.position.x <= canvasSize.width + pRadius) ||
(particle.velocity.x < 0 && particle.position.x >= -pRadius)) {
if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) ||
(particle.velocity.y < minVelocity && particle.position.y >= -pRadius) ||
(particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius) ||
(particle.velocity.x < minVelocity && particle.position.x >= -pRadius)) {
return;

@@ -28,0 +29,0 @@ }

@@ -7,3 +7,2 @@ import { BounceOutMode } from "./BounceOutMode.js";

constructor(container) {
this.container = container;
this._updateOutMode = (particle, delta, outMode, direction) => {

@@ -14,2 +13,3 @@ for (const updater of this.updaters) {

};
this.container = container;
this.updaters = [

@@ -16,0 +16,0 @@ new BounceOutMode(container),

import { Vector, calculateBounds, getDistances, getRandom, isPointInside, randomInRange, } from "@tsparticles/engine";
const minVelocity = 0, minDistance = 0;
export class OutOutMode {

@@ -20,3 +21,6 @@ constructor(container) {

const { dx, dy } = getDistances(particle.position, circVec);
if ((vx <= 0 && dx >= 0) || (vy <= 0 && dy >= 0) || (vx >= 0 && dx <= 0) || (vy >= 0 && dy <= 0)) {
if ((vx <= minVelocity && dx >= minDistance) ||
(vy <= minVelocity && dy >= minDistance) ||
(vx >= minVelocity && dx <= minDistance) ||
(vy >= minVelocity && dy <= minDistance)) {
return;

@@ -23,0 +27,0 @@ }

import { getRangeValue } from "@tsparticles/engine";
const minVelocity = 0, boundsMin = 0;
export function bounceHorizontal(data) {

@@ -10,3 +11,3 @@ if ((data.outMode !== "bounce" &&

}
if (data.bounds.right < 0 && data.direction === "left") {
if (data.bounds.right < boundsMin && data.direction === "left") {
data.particle.position.x = data.size + data.offset.x;

@@ -19,4 +20,6 @@ }

let bounced = false;
if ((data.direction === "right" && data.bounds.right >= data.canvasSize.width && velocity > 0) ||
(data.direction === "left" && data.bounds.left <= 0 && velocity < 0)) {
if ((data.direction === "right" &&
data.bounds.right >= data.canvasSize.width &&
velocity > minVelocity) ||
(data.direction === "left" && data.bounds.left <= boundsMin && velocity < minVelocity)) {
const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);

@@ -33,3 +36,3 @@ data.particle.velocity.x *= -newVelocity;

}
else if (data.bounds.left <= 0 && data.direction === "left") {
else if (data.bounds.left <= boundsMin && data.direction === "left") {
data.particle.position.x = minPos;

@@ -49,3 +52,3 @@ }

}
if (data.bounds.bottom < 0 && data.direction === "top") {
if (data.bounds.bottom < boundsMin && data.direction === "top") {
data.particle.position.y = data.size + data.offset.y;

@@ -58,4 +61,6 @@ }

let bounced = false;
if ((data.direction === "bottom" && data.bounds.bottom >= data.canvasSize.height && velocity > 0) ||
(data.direction === "top" && data.bounds.top <= 0 && velocity < 0)) {
if ((data.direction === "bottom" &&
data.bounds.bottom >= data.canvasSize.height &&
velocity > minVelocity) ||
(data.direction === "top" && data.bounds.top <= boundsMin && velocity < minVelocity)) {
const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);

@@ -72,3 +77,3 @@ data.particle.velocity.y *= -newVelocity;

}
else if (data.bounds.top <= 0 && data.direction === "top") {
else if (data.bounds.top <= boundsMin && data.direction === "top") {
data.particle.position.y = minPos;

@@ -75,0 +80,0 @@ }

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

const engine_1 = require("@tsparticles/engine");
const minVelocity = 0;
class DestroyOutMode {

@@ -26,6 +27,6 @@ constructor(container) {

const { x: vx, y: vy } = particle.velocity;
if ((vx < 0 && dx > particle.moveCenter.radius) ||
(vy < 0 && dy > particle.moveCenter.radius) ||
(vx >= 0 && dx < -particle.moveCenter.radius) ||
(vy >= 0 && dy < -particle.moveCenter.radius)) {
if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
(vy < minVelocity && dy > particle.moveCenter.radius) ||
(vx >= minVelocity && dx < -particle.moveCenter.radius) ||
(vy >= minVelocity && dy < -particle.moveCenter.radius)) {
return;

@@ -32,0 +33,0 @@ }

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

const engine_1 = require("@tsparticles/engine");
const minVelocity = 0;
class NoneOutMode {

@@ -16,3 +17,3 @@ constructor(container) {

if ((particle.options.move.distance.horizontal &&
(direction === "left" || direction === "right")) ||
(direction === "left" || direction === "right")) ??
(particle.options.move.distance.vertical &&

@@ -26,6 +27,6 @@ (direction === "top" || direction === "bottom"))) {

if (!gravityOptions.enable) {
if ((particle.velocity.y > 0 && particle.position.y <= canvasSize.height + pRadius) ||
(particle.velocity.y < 0 && particle.position.y >= -pRadius) ||
(particle.velocity.x > 0 && particle.position.x <= canvasSize.width + pRadius) ||
(particle.velocity.x < 0 && particle.position.x >= -pRadius)) {
if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) ||
(particle.velocity.y < minVelocity && particle.position.y >= -pRadius) ||
(particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius) ||
(particle.velocity.x < minVelocity && particle.position.x >= -pRadius)) {
return;

@@ -32,0 +33,0 @@ }

@@ -10,3 +10,2 @@ "use strict";

constructor(container) {
this.container = container;
this._updateOutMode = (particle, delta, outMode, direction) => {

@@ -17,2 +16,3 @@ for (const updater of this.updaters) {

};
this.container = container;
this.updaters = [

@@ -19,0 +19,0 @@ new BounceOutMode_js_1.BounceOutMode(container),

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

const engine_1 = require("@tsparticles/engine");
const minVelocity = 0, minDistance = 0;
class OutOutMode {

@@ -24,3 +25,6 @@ constructor(container) {

const { dx, dy } = (0, engine_1.getDistances)(particle.position, circVec);
if ((vx <= 0 && dx >= 0) || (vy <= 0 && dy >= 0) || (vx >= 0 && dx <= 0) || (vy >= 0 && dy <= 0)) {
if ((vx <= minVelocity && dx >= minDistance) ||
(vy <= minVelocity && dy >= minDistance) ||
(vx >= minVelocity && dx <= minDistance) ||
(vy >= minVelocity && dy <= minDistance)) {
return;

@@ -27,0 +31,0 @@ }

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

const engine_1 = require("@tsparticles/engine");
const minVelocity = 0, boundsMin = 0;
function bounceHorizontal(data) {

@@ -14,3 +15,3 @@ if ((data.outMode !== "bounce" &&

}
if (data.bounds.right < 0 && data.direction === "left") {
if (data.bounds.right < boundsMin && data.direction === "left") {
data.particle.position.x = data.size + data.offset.x;

@@ -23,4 +24,6 @@ }

let bounced = false;
if ((data.direction === "right" && data.bounds.right >= data.canvasSize.width && velocity > 0) ||
(data.direction === "left" && data.bounds.left <= 0 && velocity < 0)) {
if ((data.direction === "right" &&
data.bounds.right >= data.canvasSize.width &&
velocity > minVelocity) ||
(data.direction === "left" && data.bounds.left <= boundsMin && velocity < minVelocity)) {
const newVelocity = (0, engine_1.getRangeValue)(data.particle.options.bounce.horizontal.value);

@@ -37,3 +40,3 @@ data.particle.velocity.x *= -newVelocity;

}
else if (data.bounds.left <= 0 && data.direction === "left") {
else if (data.bounds.left <= boundsMin && data.direction === "left") {
data.particle.position.x = minPos;

@@ -54,3 +57,3 @@ }

}
if (data.bounds.bottom < 0 && data.direction === "top") {
if (data.bounds.bottom < boundsMin && data.direction === "top") {
data.particle.position.y = data.size + data.offset.y;

@@ -63,4 +66,6 @@ }

let bounced = false;
if ((data.direction === "bottom" && data.bounds.bottom >= data.canvasSize.height && velocity > 0) ||
(data.direction === "top" && data.bounds.top <= 0 && velocity < 0)) {
if ((data.direction === "bottom" &&
data.bounds.bottom >= data.canvasSize.height &&
velocity > minVelocity) ||
(data.direction === "top" && data.bounds.top <= boundsMin && velocity < minVelocity)) {
const newVelocity = (0, engine_1.getRangeValue)(data.particle.options.bounce.vertical.value);

@@ -77,3 +82,3 @@ data.particle.velocity.y *= -newVelocity;

}
else if (data.bounds.top <= 0 && data.direction === "top") {
else if (data.bounds.top <= boundsMin && data.direction === "top") {
data.particle.position.y = minPos;

@@ -80,0 +85,0 @@ }

import { Vector, getDistances, isPointInside, } from "@tsparticles/engine";
const minVelocity = 0;
export class DestroyOutMode {

@@ -22,6 +23,6 @@ constructor(container) {

const { x: vx, y: vy } = particle.velocity;
if ((vx < 0 && dx > particle.moveCenter.radius) ||
(vy < 0 && dy > particle.moveCenter.radius) ||
(vx >= 0 && dx < -particle.moveCenter.radius) ||
(vy >= 0 && dy < -particle.moveCenter.radius)) {
if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
(vy < minVelocity && dy > particle.moveCenter.radius) ||
(vx >= minVelocity && dx < -particle.moveCenter.radius) ||
(vy >= minVelocity && dy < -particle.moveCenter.radius)) {
return;

@@ -28,0 +29,0 @@ }

import { Vector, isPointInside, } from "@tsparticles/engine";
const minVelocity = 0;
export class NoneOutMode {

@@ -12,3 +13,3 @@ constructor(container) {

if ((particle.options.move.distance.horizontal &&
(direction === "left" || direction === "right")) ||
(direction === "left" || direction === "right")) ??
(particle.options.move.distance.vertical &&

@@ -22,6 +23,6 @@ (direction === "top" || direction === "bottom"))) {

if (!gravityOptions.enable) {
if ((particle.velocity.y > 0 && particle.position.y <= canvasSize.height + pRadius) ||
(particle.velocity.y < 0 && particle.position.y >= -pRadius) ||
(particle.velocity.x > 0 && particle.position.x <= canvasSize.width + pRadius) ||
(particle.velocity.x < 0 && particle.position.x >= -pRadius)) {
if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) ||
(particle.velocity.y < minVelocity && particle.position.y >= -pRadius) ||
(particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius) ||
(particle.velocity.x < minVelocity && particle.position.x >= -pRadius)) {
return;

@@ -28,0 +29,0 @@ }

@@ -7,3 +7,2 @@ import { BounceOutMode } from "./BounceOutMode.js";

constructor(container) {
this.container = container;
this._updateOutMode = (particle, delta, outMode, direction) => {

@@ -14,2 +13,3 @@ for (const updater of this.updaters) {

};
this.container = container;
this.updaters = [

@@ -16,0 +16,0 @@ new BounceOutMode(container),

import { Vector, calculateBounds, getDistances, getRandom, isPointInside, randomInRange, } from "@tsparticles/engine";
const minVelocity = 0, minDistance = 0;
export class OutOutMode {

@@ -20,3 +21,6 @@ constructor(container) {

const { dx, dy } = getDistances(particle.position, circVec);
if ((vx <= 0 && dx >= 0) || (vy <= 0 && dy >= 0) || (vx >= 0 && dx <= 0) || (vy >= 0 && dy <= 0)) {
if ((vx <= minVelocity && dx >= minDistance) ||
(vy <= minVelocity && dy >= minDistance) ||
(vx >= minVelocity && dx <= minDistance) ||
(vy >= minVelocity && dy <= minDistance)) {
return;

@@ -23,0 +27,0 @@ }

import { getRangeValue } from "@tsparticles/engine";
const minVelocity = 0, boundsMin = 0;
export function bounceHorizontal(data) {

@@ -10,3 +11,3 @@ if ((data.outMode !== "bounce" &&

}
if (data.bounds.right < 0 && data.direction === "left") {
if (data.bounds.right < boundsMin && data.direction === "left") {
data.particle.position.x = data.size + data.offset.x;

@@ -19,4 +20,6 @@ }

let bounced = false;
if ((data.direction === "right" && data.bounds.right >= data.canvasSize.width && velocity > 0) ||
(data.direction === "left" && data.bounds.left <= 0 && velocity < 0)) {
if ((data.direction === "right" &&
data.bounds.right >= data.canvasSize.width &&
velocity > minVelocity) ||
(data.direction === "left" && data.bounds.left <= boundsMin && velocity < minVelocity)) {
const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);

@@ -33,3 +36,3 @@ data.particle.velocity.x *= -newVelocity;

}
else if (data.bounds.left <= 0 && data.direction === "left") {
else if (data.bounds.left <= boundsMin && data.direction === "left") {
data.particle.position.x = minPos;

@@ -49,3 +52,3 @@ }

}
if (data.bounds.bottom < 0 && data.direction === "top") {
if (data.bounds.bottom < boundsMin && data.direction === "top") {
data.particle.position.y = data.size + data.offset.y;

@@ -58,4 +61,6 @@ }

let bounced = false;
if ((data.direction === "bottom" && data.bounds.bottom >= data.canvasSize.height && velocity > 0) ||
(data.direction === "top" && data.bounds.top <= 0 && velocity < 0)) {
if ((data.direction === "bottom" &&
data.bounds.bottom >= data.canvasSize.height &&
velocity > minVelocity) ||
(data.direction === "top" && data.bounds.top <= boundsMin && velocity < minVelocity)) {
const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);

@@ -72,3 +77,3 @@ data.particle.velocity.y *= -newVelocity;

}
else if (data.bounds.top <= 0 && data.direction === "top") {
else if (data.bounds.top <= boundsMin && data.direction === "top") {
data.particle.position.y = minPos;

@@ -75,0 +80,0 @@ }

{
"name": "@tsparticles/updater-out-modes",
"version": "3.0.3",
"version": "3.1.0",
"description": "tsParticles particles out modes updater",

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

"dependencies": {
"@tsparticles/engine": "^3.0.3"
"@tsparticles/engine": "^3.1.0"
},

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

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

* How to use? : Check the GitHub README
* v3.0.3
* v3.1.0
*/

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

const minVelocity = 0,
boundsMin = 0;
function bounceHorizontal(data) {

@@ -107,3 +109,3 @@ if (data.outMode !== "bounce" && data.outMode !== "bounce-horizontal" && data.outMode !== "bounceHorizontal" && data.outMode !== "split" || data.direction !== "left" && data.direction !== "right") {

}
if (data.bounds.right < 0 && data.direction === "left") {
if (data.bounds.right < boundsMin && data.direction === "left") {
data.particle.position.x = data.size + data.offset.x;

@@ -115,3 +117,3 @@ } else if (data.bounds.left > data.canvasSize.width && data.direction === "right") {

let bounced = false;
if (data.direction === "right" && data.bounds.right >= data.canvasSize.width && velocity > 0 || data.direction === "left" && data.bounds.left <= 0 && velocity < 0) {
if (data.direction === "right" && data.bounds.right >= data.canvasSize.width && velocity > minVelocity || data.direction === "left" && data.bounds.left <= boundsMin && velocity < minVelocity) {
const newVelocity = (0,engine_root_window_.getRangeValue)(data.particle.options.bounce.horizontal.value);

@@ -127,3 +129,3 @@ data.particle.velocity.x *= -newVelocity;

data.particle.position.x = data.canvasSize.width - minPos;
} else if (data.bounds.left <= 0 && data.direction === "left") {
} else if (data.bounds.left <= boundsMin && data.direction === "left") {
data.particle.position.x = minPos;

@@ -139,3 +141,3 @@ }

}
if (data.bounds.bottom < 0 && data.direction === "top") {
if (data.bounds.bottom < boundsMin && data.direction === "top") {
data.particle.position.y = data.size + data.offset.y;

@@ -147,3 +149,3 @@ } else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") {

let bounced = false;
if (data.direction === "bottom" && data.bounds.bottom >= data.canvasSize.height && velocity > 0 || data.direction === "top" && data.bounds.top <= 0 && velocity < 0) {
if (data.direction === "bottom" && data.bounds.bottom >= data.canvasSize.height && velocity > minVelocity || data.direction === "top" && data.bounds.top <= boundsMin && velocity < minVelocity) {
const newVelocity = (0,engine_root_window_.getRangeValue)(data.particle.options.bounce.vertical.value);

@@ -159,3 +161,3 @@ data.particle.velocity.y *= -newVelocity;

data.particle.position.y = data.canvasSize.height - minPos;
} else if (data.bounds.top <= 0 && data.direction === "top") {
} else if (data.bounds.top <= boundsMin && data.direction === "top") {
data.particle.position.y = minPos;

@@ -219,2 +221,3 @@ }

const DestroyOutMode_minVelocity = 0;
class DestroyOutMode {

@@ -247,3 +250,3 @@ constructor(container) {

} = particle.velocity;
if (vx < 0 && dx > particle.moveCenter.radius || vy < 0 && dy > particle.moveCenter.radius || vx >= 0 && dx < -particle.moveCenter.radius || vy >= 0 && dy < -particle.moveCenter.radius) {
if (vx < DestroyOutMode_minVelocity && dx > particle.moveCenter.radius || vy < DestroyOutMode_minVelocity && dy > particle.moveCenter.radius || vx >= DestroyOutMode_minVelocity && dx < -particle.moveCenter.radius || vy >= DestroyOutMode_minVelocity && dy < -particle.moveCenter.radius) {
return;

@@ -259,2 +262,3 @@ }

const NoneOutMode_minVelocity = 0;
class NoneOutMode {

@@ -269,3 +273,3 @@ constructor(container) {

}
if (particle.options.move.distance.horizontal && (direction === "left" || direction === "right") || particle.options.move.distance.vertical && (direction === "top" || direction === "bottom")) {
if ((particle.options.move.distance.horizontal && (direction === "left" || direction === "right")) ?? (particle.options.move.distance.vertical && (direction === "top" || direction === "bottom"))) {
return;

@@ -278,3 +282,3 @@ }

if (!gravityOptions.enable) {
if (particle.velocity.y > 0 && particle.position.y <= canvasSize.height + pRadius || particle.velocity.y < 0 && particle.position.y >= -pRadius || particle.velocity.x > 0 && particle.position.x <= canvasSize.width + pRadius || particle.velocity.x < 0 && particle.position.x >= -pRadius) {
if (particle.velocity.y > NoneOutMode_minVelocity && particle.position.y <= canvasSize.height + pRadius || particle.velocity.y < NoneOutMode_minVelocity && particle.position.y >= -pRadius || particle.velocity.x > NoneOutMode_minVelocity && particle.position.x <= canvasSize.width + pRadius || particle.velocity.x < NoneOutMode_minVelocity && particle.position.x >= -pRadius) {
return;

@@ -295,2 +299,4 @@ }

const OutOutMode_minVelocity = 0,
minDistance = 0;
class OutOutMode {

@@ -321,3 +327,3 @@ constructor(container) {

} = (0,engine_root_window_.getDistances)(particle.position, circVec);
if (vx <= 0 && dx >= 0 || vy <= 0 && dy >= 0 || vx >= 0 && dx <= 0 || vy >= 0 && dy <= 0) {
if (vx <= OutOutMode_minVelocity && dx >= minDistance || vy <= OutOutMode_minVelocity && dy >= minDistance || vx >= OutOutMode_minVelocity && dx <= minDistance || vy >= OutOutMode_minVelocity && dy <= minDistance) {
return;

@@ -424,3 +430,2 @@ }

constructor(container) {
this.container = container;
this._updateOutMode = (particle, delta, outMode, direction) => {

@@ -431,2 +436,3 @@ for (const updater of this.updaters) {

};
this.container = container;
this.updaters = [new BounceOutMode(container), new DestroyOutMode(container), new OutOutMode(container), new NoneOutMode(container)];

@@ -433,0 +439,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={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.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 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})()));
!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})()));

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

/*! tsParticles Out Modes Updater v3.0.3 by Matteo Bruni */
/*! tsParticles Out Modes Updater v3.1.0 by Matteo Bruni */
import { type Container, type IDelta, type IParticleUpdater, type Particle } from "@tsparticles/engine";
import type { IOutModeManager } from "./IOutModeManager.js";
export declare class OutOfCanvasUpdater implements IParticleUpdater {
updaters: IOutModeManager[];
private readonly container;
updaters: IOutModeManager[];
constructor(container: Container);

@@ -7,0 +7,0 @@ init(): void;

@@ -14,2 +14,3 @@ (function (factory) {

const engine_1 = require("@tsparticles/engine");
const minVelocity = 0;
class DestroyOutMode {

@@ -35,6 +36,6 @@ constructor(container) {

const { x: vx, y: vy } = particle.velocity;
if ((vx < 0 && dx > particle.moveCenter.radius) ||
(vy < 0 && dy > particle.moveCenter.radius) ||
(vx >= 0 && dx < -particle.moveCenter.radius) ||
(vy >= 0 && dy < -particle.moveCenter.radius)) {
if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
(vy < minVelocity && dy > particle.moveCenter.radius) ||
(vx >= minVelocity && dx < -particle.moveCenter.radius) ||
(vy >= minVelocity && dy < -particle.moveCenter.radius)) {
return;

@@ -41,0 +42,0 @@ }

@@ -14,2 +14,3 @@ (function (factory) {

const engine_1 = require("@tsparticles/engine");
const minVelocity = 0;
class NoneOutMode {

@@ -25,3 +26,3 @@ constructor(container) {

if ((particle.options.move.distance.horizontal &&
(direction === "left" || direction === "right")) ||
(direction === "left" || direction === "right")) ??
(particle.options.move.distance.vertical &&

@@ -35,6 +36,6 @@ (direction === "top" || direction === "bottom"))) {

if (!gravityOptions.enable) {
if ((particle.velocity.y > 0 && particle.position.y <= canvasSize.height + pRadius) ||
(particle.velocity.y < 0 && particle.position.y >= -pRadius) ||
(particle.velocity.x > 0 && particle.position.x <= canvasSize.width + pRadius) ||
(particle.velocity.x < 0 && particle.position.x >= -pRadius)) {
if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) ||
(particle.velocity.y < minVelocity && particle.position.y >= -pRadius) ||
(particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius) ||
(particle.velocity.x < minVelocity && particle.position.x >= -pRadius)) {
return;

@@ -41,0 +42,0 @@ }

@@ -19,3 +19,2 @@ (function (factory) {

constructor(container) {
this.container = container;
this._updateOutMode = (particle, delta, outMode, direction) => {

@@ -26,2 +25,3 @@ for (const updater of this.updaters) {

};
this.container = container;
this.updaters = [

@@ -28,0 +28,0 @@ new BounceOutMode_js_1.BounceOutMode(container),

@@ -14,2 +14,3 @@ (function (factory) {

const engine_1 = require("@tsparticles/engine");
const minVelocity = 0, minDistance = 0;
class OutOutMode {

@@ -33,3 +34,6 @@ constructor(container) {

const { dx, dy } = (0, engine_1.getDistances)(particle.position, circVec);
if ((vx <= 0 && dx >= 0) || (vy <= 0 && dy >= 0) || (vx >= 0 && dx <= 0) || (vy >= 0 && dy <= 0)) {
if ((vx <= minVelocity && dx >= minDistance) ||
(vy <= minVelocity && dy >= minDistance) ||
(vx >= minVelocity && dx <= minDistance) ||
(vy >= minVelocity && dy <= minDistance)) {
return;

@@ -36,0 +40,0 @@ }

@@ -14,2 +14,3 @@ (function (factory) {

const engine_1 = require("@tsparticles/engine");
const minVelocity = 0, boundsMin = 0;
function bounceHorizontal(data) {

@@ -23,3 +24,3 @@ if ((data.outMode !== "bounce" &&

}
if (data.bounds.right < 0 && data.direction === "left") {
if (data.bounds.right < boundsMin && data.direction === "left") {
data.particle.position.x = data.size + data.offset.x;

@@ -32,4 +33,6 @@ }

let bounced = false;
if ((data.direction === "right" && data.bounds.right >= data.canvasSize.width && velocity > 0) ||
(data.direction === "left" && data.bounds.left <= 0 && velocity < 0)) {
if ((data.direction === "right" &&
data.bounds.right >= data.canvasSize.width &&
velocity > minVelocity) ||
(data.direction === "left" && data.bounds.left <= boundsMin && velocity < minVelocity)) {
const newVelocity = (0, engine_1.getRangeValue)(data.particle.options.bounce.horizontal.value);

@@ -46,3 +49,3 @@ data.particle.velocity.x *= -newVelocity;

}
else if (data.bounds.left <= 0 && data.direction === "left") {
else if (data.bounds.left <= boundsMin && data.direction === "left") {
data.particle.position.x = minPos;

@@ -63,3 +66,3 @@ }

}
if (data.bounds.bottom < 0 && data.direction === "top") {
if (data.bounds.bottom < boundsMin && data.direction === "top") {
data.particle.position.y = data.size + data.offset.y;

@@ -72,4 +75,6 @@ }

let bounced = false;
if ((data.direction === "bottom" && data.bounds.bottom >= data.canvasSize.height && velocity > 0) ||
(data.direction === "top" && data.bounds.top <= 0 && velocity < 0)) {
if ((data.direction === "bottom" &&
data.bounds.bottom >= data.canvasSize.height &&
velocity > minVelocity) ||
(data.direction === "top" && data.bounds.top <= boundsMin && velocity < minVelocity)) {
const newVelocity = (0, engine_1.getRangeValue)(data.particle.options.bounce.vertical.value);

@@ -86,3 +91,3 @@ data.particle.velocity.y *= -newVelocity;

}
else if (data.bounds.top <= 0 && data.direction === "top") {
else if (data.bounds.top <= boundsMin && data.direction === "top") {
data.particle.position.y = minPos;

@@ -89,0 +94,0 @@ }

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