tsparticles-updater-out-modes
Advanced tools
Comparing version 2.11.1 to 2.12.0
@@ -7,3 +7,3 @@ import { Vector, getDistances, isPointInside, } from "tsparticles-engine"; | ||
} | ||
update(particle, direction, delta, outMode) { | ||
update(particle, direction, _delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -10,0 +10,0 @@ return; |
import { getValue } from "tsparticles-engine"; | ||
export function bounceHorizontal(data) { | ||
if (data.outMode !== "bounce" && | ||
if ((data.outMode !== "bounce" && | ||
data.outMode !== "bounce-horizontal" && | ||
data.outMode !== "bounceHorizontal" && | ||
data.outMode !== "split") { | ||
data.outMode !== "split") || | ||
(data.direction !== "left" && data.direction !== "right")) { | ||
return; | ||
} | ||
if (data.bounds.right < 0) { | ||
if (data.bounds.right < 0 && data.direction === "left") { | ||
data.particle.position.x = data.size + data.offset.x; | ||
} | ||
else if (data.bounds.left > data.canvasSize.width) { | ||
else if (data.bounds.left > data.canvasSize.width && data.direction === "right") { | ||
data.particle.position.x = data.canvasSize.width - data.size - data.offset.x; | ||
@@ -27,6 +28,6 @@ } | ||
const minPos = data.offset.x + data.size; | ||
if (data.bounds.right >= data.canvasSize.width) { | ||
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") { | ||
data.particle.position.x = data.canvasSize.width - minPos; | ||
} | ||
else if (data.bounds.left <= 0) { | ||
else if (data.bounds.left <= 0 && data.direction === "left") { | ||
data.particle.position.x = minPos; | ||
@@ -39,12 +40,13 @@ } | ||
export function bounceVertical(data) { | ||
if (data.outMode !== "bounce" && | ||
if ((data.outMode !== "bounce" && | ||
data.outMode !== "bounce-vertical" && | ||
data.outMode !== "bounceVertical" && | ||
data.outMode !== "split") { | ||
data.outMode !== "split") || | ||
(data.direction !== "bottom" && data.direction !== "top")) { | ||
return; | ||
} | ||
if (data.bounds.bottom < 0) { | ||
if (data.bounds.bottom < 0 && data.direction === "top") { | ||
data.particle.position.y = data.size + data.offset.y; | ||
} | ||
else if (data.bounds.top > data.canvasSize.height) { | ||
else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") { | ||
data.particle.position.y = data.canvasSize.height - data.size - data.offset.y; | ||
@@ -64,6 +66,6 @@ } | ||
const minPos = data.offset.y + data.size; | ||
if (data.bounds.bottom >= data.canvasSize.height) { | ||
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") { | ||
data.particle.position.y = data.canvasSize.height - minPos; | ||
} | ||
else if (data.bounds.top <= 0) { | ||
else if (data.bounds.top <= 0 && data.direction === "top") { | ||
data.particle.position.y = minPos; | ||
@@ -70,0 +72,0 @@ } |
@@ -10,3 +10,3 @@ "use strict"; | ||
} | ||
update(particle, direction, delta, outMode) { | ||
update(particle, direction, _delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -13,0 +13,0 @@ return; |
@@ -6,12 +6,13 @@ "use strict"; | ||
function bounceHorizontal(data) { | ||
if (data.outMode !== "bounce" && | ||
if ((data.outMode !== "bounce" && | ||
data.outMode !== "bounce-horizontal" && | ||
data.outMode !== "bounceHorizontal" && | ||
data.outMode !== "split") { | ||
data.outMode !== "split") || | ||
(data.direction !== "left" && data.direction !== "right")) { | ||
return; | ||
} | ||
if (data.bounds.right < 0) { | ||
if (data.bounds.right < 0 && data.direction === "left") { | ||
data.particle.position.x = data.size + data.offset.x; | ||
} | ||
else if (data.bounds.left > data.canvasSize.width) { | ||
else if (data.bounds.left > data.canvasSize.width && data.direction === "right") { | ||
data.particle.position.x = data.canvasSize.width - data.size - data.offset.x; | ||
@@ -31,6 +32,6 @@ } | ||
const minPos = data.offset.x + data.size; | ||
if (data.bounds.right >= data.canvasSize.width) { | ||
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") { | ||
data.particle.position.x = data.canvasSize.width - minPos; | ||
} | ||
else if (data.bounds.left <= 0) { | ||
else if (data.bounds.left <= 0 && data.direction === "left") { | ||
data.particle.position.x = minPos; | ||
@@ -44,12 +45,13 @@ } | ||
function bounceVertical(data) { | ||
if (data.outMode !== "bounce" && | ||
if ((data.outMode !== "bounce" && | ||
data.outMode !== "bounce-vertical" && | ||
data.outMode !== "bounceVertical" && | ||
data.outMode !== "split") { | ||
data.outMode !== "split") || | ||
(data.direction !== "bottom" && data.direction !== "top")) { | ||
return; | ||
} | ||
if (data.bounds.bottom < 0) { | ||
if (data.bounds.bottom < 0 && data.direction === "top") { | ||
data.particle.position.y = data.size + data.offset.y; | ||
} | ||
else if (data.bounds.top > data.canvasSize.height) { | ||
else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") { | ||
data.particle.position.y = data.canvasSize.height - data.size - data.offset.y; | ||
@@ -69,6 +71,6 @@ } | ||
const minPos = data.offset.y + data.size; | ||
if (data.bounds.bottom >= data.canvasSize.height) { | ||
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") { | ||
data.particle.position.y = data.canvasSize.height - minPos; | ||
} | ||
else if (data.bounds.top <= 0) { | ||
else if (data.bounds.top <= 0 && data.direction === "top") { | ||
data.particle.position.y = minPos; | ||
@@ -75,0 +77,0 @@ } |
@@ -7,3 +7,3 @@ import { Vector, getDistances, isPointInside, } from "tsparticles-engine"; | ||
} | ||
update(particle, direction, delta, outMode) { | ||
update(particle, direction, _delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -10,0 +10,0 @@ return; |
import { getValue } from "tsparticles-engine"; | ||
export function bounceHorizontal(data) { | ||
if (data.outMode !== "bounce" && | ||
if ((data.outMode !== "bounce" && | ||
data.outMode !== "bounce-horizontal" && | ||
data.outMode !== "bounceHorizontal" && | ||
data.outMode !== "split") { | ||
data.outMode !== "split") || | ||
(data.direction !== "left" && data.direction !== "right")) { | ||
return; | ||
} | ||
if (data.bounds.right < 0) { | ||
if (data.bounds.right < 0 && data.direction === "left") { | ||
data.particle.position.x = data.size + data.offset.x; | ||
} | ||
else if (data.bounds.left > data.canvasSize.width) { | ||
else if (data.bounds.left > data.canvasSize.width && data.direction === "right") { | ||
data.particle.position.x = data.canvasSize.width - data.size - data.offset.x; | ||
@@ -27,6 +28,6 @@ } | ||
const minPos = data.offset.x + data.size; | ||
if (data.bounds.right >= data.canvasSize.width) { | ||
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") { | ||
data.particle.position.x = data.canvasSize.width - minPos; | ||
} | ||
else if (data.bounds.left <= 0) { | ||
else if (data.bounds.left <= 0 && data.direction === "left") { | ||
data.particle.position.x = minPos; | ||
@@ -39,12 +40,13 @@ } | ||
export function bounceVertical(data) { | ||
if (data.outMode !== "bounce" && | ||
if ((data.outMode !== "bounce" && | ||
data.outMode !== "bounce-vertical" && | ||
data.outMode !== "bounceVertical" && | ||
data.outMode !== "split") { | ||
data.outMode !== "split") || | ||
(data.direction !== "bottom" && data.direction !== "top")) { | ||
return; | ||
} | ||
if (data.bounds.bottom < 0) { | ||
if (data.bounds.bottom < 0 && data.direction === "top") { | ||
data.particle.position.y = data.size + data.offset.y; | ||
} | ||
else if (data.bounds.top > data.canvasSize.height) { | ||
else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") { | ||
data.particle.position.y = data.canvasSize.height - data.size - data.offset.y; | ||
@@ -64,6 +66,6 @@ } | ||
const minPos = data.offset.y + data.size; | ||
if (data.bounds.bottom >= data.canvasSize.height) { | ||
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") { | ||
data.particle.position.y = data.canvasSize.height - minPos; | ||
} | ||
else if (data.bounds.top <= 0) { | ||
else if (data.bounds.top <= 0 && data.direction === "top") { | ||
data.particle.position.y = minPos; | ||
@@ -70,0 +72,0 @@ } |
{ | ||
"name": "tsparticles-updater-out-modes", | ||
"version": "2.11.1", | ||
"version": "2.12.0", | ||
"description": "tsParticles particles out modes updater", | ||
@@ -78,4 +78,4 @@ "homepage": "https://particles.js.org", | ||
"dependencies": { | ||
"tsparticles-engine": "^2.11.1" | ||
"tsparticles-engine": "^2.12.0" | ||
} | ||
} | ||
} |
@@ -7,3 +7,3 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v2.11.1 | ||
* v2.12.0 | ||
*/ | ||
@@ -103,8 +103,8 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
function bounceHorizontal(data) { | ||
if (data.outMode !== "bounce" && data.outMode !== "bounce-horizontal" && data.outMode !== "bounceHorizontal" && data.outMode !== "split") { | ||
if (data.outMode !== "bounce" && data.outMode !== "bounce-horizontal" && data.outMode !== "bounceHorizontal" && data.outMode !== "split" || data.direction !== "left" && data.direction !== "right") { | ||
return; | ||
} | ||
if (data.bounds.right < 0) { | ||
if (data.bounds.right < 0 && data.direction === "left") { | ||
data.particle.position.x = data.size + data.offset.x; | ||
} else if (data.bounds.left > data.canvasSize.width) { | ||
} else if (data.bounds.left > data.canvasSize.width && data.direction === "right") { | ||
data.particle.position.x = data.canvasSize.width - data.size - data.offset.x; | ||
@@ -123,5 +123,5 @@ } | ||
const minPos = data.offset.x + data.size; | ||
if (data.bounds.right >= data.canvasSize.width) { | ||
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") { | ||
data.particle.position.x = data.canvasSize.width - minPos; | ||
} else if (data.bounds.left <= 0) { | ||
} else if (data.bounds.left <= 0 && data.direction === "left") { | ||
data.particle.position.x = minPos; | ||
@@ -134,8 +134,8 @@ } | ||
function bounceVertical(data) { | ||
if (data.outMode !== "bounce" && data.outMode !== "bounce-vertical" && data.outMode !== "bounceVertical" && data.outMode !== "split") { | ||
if (data.outMode !== "bounce" && data.outMode !== "bounce-vertical" && data.outMode !== "bounceVertical" && data.outMode !== "split" || data.direction !== "bottom" && data.direction !== "top") { | ||
return; | ||
} | ||
if (data.bounds.bottom < 0) { | ||
if (data.bounds.bottom < 0 && data.direction === "top") { | ||
data.particle.position.y = data.size + data.offset.y; | ||
} else if (data.bounds.top > data.canvasSize.height) { | ||
} else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") { | ||
data.particle.position.y = data.canvasSize.height - data.size - data.offset.y; | ||
@@ -154,5 +154,5 @@ } | ||
const minPos = data.offset.y + data.size; | ||
if (data.bounds.bottom >= data.canvasSize.height) { | ||
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") { | ||
data.particle.position.y = data.canvasSize.height - minPos; | ||
} else if (data.bounds.top <= 0) { | ||
} else if (data.bounds.top <= 0 && data.direction === "top") { | ||
data.particle.position.y = minPos; | ||
@@ -221,3 +221,3 @@ } | ||
} | ||
update(particle, direction, delta, outMode) { | ||
update(particle, direction, _delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -224,0 +224,0 @@ return; |
/*! 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,e=!0){await t.addParticleUpdater("outModes",(t=>new r(t)),e)}})(),n})())); | ||
!function(t,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("tsparticles-engine"));else if("function"==typeof define&&define.amd)define(["tsparticles-engine"],o);else{var e="object"==typeof exports?o(require("tsparticles-engine")):o(t.window);for(var i in e)("object"==typeof exports?exports:t)[i]=e[i]}}(this,(t=>(()=>{"use strict";var o={961:o=>{o.exports=t}},e={};function i(t){var n=e[t];if(void 0!==n)return n.exports;var s=e[t]={exports:{}};return o[t](s,s.exports,i),s.exports}i.d=(t,o)=>{for(var e in o)i.o(o,e)&&!i.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:o[e]})},i.o=(t,o)=>Object.prototype.hasOwnProperty.call(t,o),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 o{constructor(t){this.container=t,this.modes=["bounce","bounce-vertical","bounce-horizontal","bounceVertical","bounceHorizontal","split"]}update(o,e,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(o,i,e)),r)break;if(r)return;const a=o.getPosition(),c=o.offset,d=o.getRadius(),u=(0,t.calculateBounds)(a,d),p=s.canvas.size;!function(o){if("bounce"!==o.outMode&&"bounce-horizontal"!==o.outMode&&"bounceHorizontal"!==o.outMode&&"split"!==o.outMode||"left"!==o.direction&&"right"!==o.direction)return;o.bounds.right<0&&"left"===o.direction?o.particle.position.x=o.size+o.offset.x:o.bounds.left>o.canvasSize.width&&"right"===o.direction&&(o.particle.position.x=o.canvasSize.width-o.size-o.offset.x);const e=o.particle.velocity.x;let i=!1;if("right"===o.direction&&o.bounds.right>=o.canvasSize.width&&e>0||"left"===o.direction&&o.bounds.left<=0&&e<0){const e=(0,t.getValue)(o.particle.options.bounce.horizontal);o.particle.velocity.x*=-e,i=!0}if(!i)return;const n=o.offset.x+o.size;o.bounds.right>=o.canvasSize.width&&"right"===o.direction?o.particle.position.x=o.canvasSize.width-n:o.bounds.left<=0&&"left"===o.direction&&(o.particle.position.x=n),"split"===o.outMode&&o.particle.destroy()}({particle:o,outMode:n,direction:e,bounds:u,canvasSize:p,offset:c,size:d}),function(o){if("bounce"!==o.outMode&&"bounce-vertical"!==o.outMode&&"bounceVertical"!==o.outMode&&"split"!==o.outMode||"bottom"!==o.direction&&"top"!==o.direction)return;o.bounds.bottom<0&&"top"===o.direction?o.particle.position.y=o.size+o.offset.y:o.bounds.top>o.canvasSize.height&&"bottom"===o.direction&&(o.particle.position.y=o.canvasSize.height-o.size-o.offset.y);const e=o.particle.velocity.y;let i=!1;if("bottom"===o.direction&&o.bounds.bottom>=o.canvasSize.height&&e>0||"top"===o.direction&&o.bounds.top<=0&&e<0){const e=(0,t.getValue)(o.particle.options.bounce.vertical);o.particle.velocity.y*=-e,i=!0}if(!i)return;const n=o.offset.y+o.size;o.bounds.bottom>=o.canvasSize.height&&"bottom"===o.direction?o.particle.position.y=o.canvasSize.height-n:o.bounds.top<=0&&"top"===o.direction&&(o.particle.position.y=n),"split"===o.outMode&&o.particle.destroy()}({particle:o,outMode:n,direction:e,bounds:u,canvasSize:p,offset:c,size:d})}}class e{constructor(t){this.container=t,this.modes=["destroy"]}update(o,e,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(o.outType){case"normal":case"outside":if((0,t.isPointInside)(o.position,s.canvas.size,t.Vector.origin,o.getRadius(),e))return;break;case"inside":{const{dx:e,dy:i}=(0,t.getDistances)(o.position,o.moveCenter),{x:n,y:s}=o.velocity;if(n<0&&e>o.moveCenter.radius||s<0&&i>o.moveCenter.radius||n>=0&&e<-o.moveCenter.radius||s>=0&&i<-o.moveCenter.radius)return;break}}s.particles.remove(o,void 0,!0)}}class s{constructor(t){this.container=t,this.modes=["none"]}update(o,e,i,n){if(!this.modes.includes(n))return;if(o.options.move.distance.horizontal&&("left"===e||"right"===e)||o.options.move.distance.vertical&&("top"===e||"bottom"===e))return;const s=o.options.move.gravity,r=this.container,a=r.canvas.size,c=o.getRadius();if(s.enable){const t=o.position;(!s.inverse&&t.y>a.height+c&&"bottom"===e||s.inverse&&t.y<-c&&"top"===e)&&r.particles.remove(o)}else{if(o.velocity.y>0&&o.position.y<=a.height+c||o.velocity.y<0&&o.position.y>=-c||o.velocity.x>0&&o.position.x<=a.width+c||o.velocity.x<0&&o.position.x>=-c)return;(0,t.isPointInside)(o.position,r.canvas.size,t.Vector.origin,c,e)||r.particles.remove(o)}}}class r{constructor(t){this.container=t,this.modes=["out"]}update(o,e,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(o.outType){case"inside":{const{x:e,y:i}=o.velocity,n=t.Vector.origin;n.length=o.moveCenter.radius,n.angle=o.velocity.angle+Math.PI,n.addTo(t.Vector.create(o.moveCenter));const{dx:r,dy:a}=(0,t.getDistances)(o.position,n);if(e<=0&&r>=0||i<=0&&a>=0||e>=0&&r<=0||i>=0&&a<=0)return;o.position.x=Math.floor((0,t.randomInRange)({min:0,max:s.canvas.size.width})),o.position.y=Math.floor((0,t.randomInRange)({min:0,max:s.canvas.size.height}));const{dx:c,dy:d}=(0,t.getDistances)(o.position,o.moveCenter);o.direction=Math.atan2(-d,-c),o.velocity.angle=o.direction;break}default:if((0,t.isPointInside)(o.position,s.canvas.size,t.Vector.origin,o.getRadius(),e))return;switch(o.outType){case"outside":{o.position.x=Math.floor((0,t.randomInRange)({min:-o.moveCenter.radius,max:o.moveCenter.radius}))+o.moveCenter.x,o.position.y=Math.floor((0,t.randomInRange)({min:-o.moveCenter.radius,max:o.moveCenter.radius}))+o.moveCenter.y;const{dx:e,dy:i}=(0,t.getDistances)(o.position,o.moveCenter);o.moveCenter.radius&&(o.direction=Math.atan2(i,e),o.velocity.angle=o.direction);break}case"normal":{const i=o.options.move.warp,n=s.canvas.size,r={bottom:n.height+o.getRadius()+o.offset.y,left:-o.getRadius()-o.offset.x,right:n.width+o.getRadius()+o.offset.x,top:-o.getRadius()-o.offset.y},a=o.getRadius(),c=(0,t.calculateBounds)(o.position,a);"right"===e&&c.left>n.width+o.offset.x?(o.position.x=r.left,o.initialPosition.x=o.position.x,i||(o.position.y=(0,t.getRandom)()*n.height,o.initialPosition.y=o.position.y)):"left"===e&&c.right<-o.offset.x&&(o.position.x=r.right,o.initialPosition.x=o.position.x,i||(o.position.y=(0,t.getRandom)()*n.height,o.initialPosition.y=o.position.y)),"bottom"===e&&c.top>n.height+o.offset.y?(i||(o.position.x=(0,t.getRandom)()*n.width,o.initialPosition.x=o.position.x),o.position.y=r.top,o.initialPosition.y=o.position.y):"top"===e&&c.bottom<-o.offset.y&&(i||(o.position.x=(0,t.getRandom)()*n.width,o.initialPosition.x=o.position.x),o.position.y=r.bottom,o.initialPosition.y=o.position.y);break}}}}}class a{constructor(t){this.container=t,this._updateOutMode=(t,o,e,i)=>{for(const n of this.updaters)n.update(t,i,o,e)},this.updaters=[new o(t),new e(t),new r(t),new s(t)]}init(){}isEnabled(t){return!t.destroyed&&!t.spawning}update(t,o){const e=t.options.move.outModes;this._updateOutMode(t,o,e.bottom??e.default,"bottom"),this._updateOutMode(t,o,e.left??e.default,"left"),this._updateOutMode(t,o,e.right??e.default,"right"),this._updateOutMode(t,o,e.top??e.default,"top")}}async function c(t,o=!0){await t.addParticleUpdater("outModes",(t=>new a(t)),o)}})(),n})())); |
@@ -1,1 +0,1 @@ | ||
/*! tsParticles Out Modes Updater v2.11.1 by Matteo Bruni */ | ||
/*! tsParticles Out Modes Updater v2.12.0 by Matteo Bruni */ |
@@ -7,3 +7,3 @@ import { type Container, type IDelta, OutMode, type OutModeAlt, type OutModeDirection, type Particle } from "tsparticles-engine"; | ||
constructor(container: Container); | ||
update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void; | ||
update(particle: Particle, direction: OutModeDirection, _delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void; | ||
} |
@@ -19,3 +19,3 @@ (function (factory) { | ||
} | ||
update(particle, direction, delta, outMode) { | ||
update(particle, direction, _delta, outMode) { | ||
if (!this.modes.includes(outMode)) { | ||
@@ -22,0 +22,0 @@ return; |
@@ -15,12 +15,13 @@ (function (factory) { | ||
function bounceHorizontal(data) { | ||
if (data.outMode !== "bounce" && | ||
if ((data.outMode !== "bounce" && | ||
data.outMode !== "bounce-horizontal" && | ||
data.outMode !== "bounceHorizontal" && | ||
data.outMode !== "split") { | ||
data.outMode !== "split") || | ||
(data.direction !== "left" && data.direction !== "right")) { | ||
return; | ||
} | ||
if (data.bounds.right < 0) { | ||
if (data.bounds.right < 0 && data.direction === "left") { | ||
data.particle.position.x = data.size + data.offset.x; | ||
} | ||
else if (data.bounds.left > data.canvasSize.width) { | ||
else if (data.bounds.left > data.canvasSize.width && data.direction === "right") { | ||
data.particle.position.x = data.canvasSize.width - data.size - data.offset.x; | ||
@@ -40,6 +41,6 @@ } | ||
const minPos = data.offset.x + data.size; | ||
if (data.bounds.right >= data.canvasSize.width) { | ||
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") { | ||
data.particle.position.x = data.canvasSize.width - minPos; | ||
} | ||
else if (data.bounds.left <= 0) { | ||
else if (data.bounds.left <= 0 && data.direction === "left") { | ||
data.particle.position.x = minPos; | ||
@@ -53,12 +54,13 @@ } | ||
function bounceVertical(data) { | ||
if (data.outMode !== "bounce" && | ||
if ((data.outMode !== "bounce" && | ||
data.outMode !== "bounce-vertical" && | ||
data.outMode !== "bounceVertical" && | ||
data.outMode !== "split") { | ||
data.outMode !== "split") || | ||
(data.direction !== "bottom" && data.direction !== "top")) { | ||
return; | ||
} | ||
if (data.bounds.bottom < 0) { | ||
if (data.bounds.bottom < 0 && data.direction === "top") { | ||
data.particle.position.y = data.size + data.offset.y; | ||
} | ||
else if (data.bounds.top > data.canvasSize.height) { | ||
else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") { | ||
data.particle.position.y = data.canvasSize.height - data.size - data.offset.y; | ||
@@ -78,6 +80,6 @@ } | ||
const minPos = data.offset.y + data.size; | ||
if (data.bounds.bottom >= data.canvasSize.height) { | ||
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") { | ||
data.particle.position.y = data.canvasSize.height - minPos; | ||
} | ||
else if (data.bounds.top <= 0) { | ||
else if (data.bounds.top <= 0 && data.direction === "top") { | ||
data.particle.position.y = minPos; | ||
@@ -84,0 +86,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
381579
1951
Updatedtsparticles-engine@^2.12.0