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

@tsparticles/updater-destroy

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-destroy - npm Package Compare versions

Comparing version 3.0.3 to 3.1.0

12

browser/DestroyUpdater.js

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

import { getRangeValue, } from "@tsparticles/engine";
import { getRangeValue, percentDenominator, } from "@tsparticles/engine";
import { Destroy } from "./Options/Classes/Destroy.js";

@@ -6,4 +6,4 @@ import { split } from "./Utils.js";

constructor(engine, container) {
this.container = container;
this.engine = engine;
this.container = container;
}

@@ -22,12 +22,12 @@ init(particle) {

if (bottom) {
destroyBounds.bottom = (getRangeValue(bottom) * canvasSize.height) / 100;
destroyBounds.bottom = (getRangeValue(bottom) * canvasSize.height) / percentDenominator;
}
if (left) {
destroyBounds.left = (getRangeValue(left) * canvasSize.width) / 100;
destroyBounds.left = (getRangeValue(left) * canvasSize.width) / percentDenominator;
}
if (right) {
destroyBounds.right = (getRangeValue(right) * canvasSize.width) / 100;
destroyBounds.right = (getRangeValue(right) * canvasSize.width) / percentDenominator;
}
if (top) {
destroyBounds.top = (getRangeValue(top) * canvasSize.height) / 100;
destroyBounds.top = (getRangeValue(top) * canvasSize.height) / percentDenominator;
}

@@ -34,0 +34,0 @@ }

import { getRangeValue, isNumber, itemFromSingleOrMultiple, loadParticlesOptions, randomInRange, setRangeValue, } from "@tsparticles/engine";
const defaultOffset = 0, minDestroySize = 0.5, defaultSplitCount = 0, increment = 1, unbreakableTime = 500, minSplitCount = 0;
function addSplitParticle(engine, container, parent, splitParticlesOptions) {

@@ -15,5 +16,5 @@ const destroyOptions = parent.options.destroy;

hsl: {
h: parentColor.h + getRangeValue(splitOptions.colorOffset.h ?? 0),
s: parentColor.s + getRangeValue(splitOptions.colorOffset.s ?? 0),
l: parentColor.l + getRangeValue(splitOptions.colorOffset.l ?? 0),
h: parentColor.h + getRangeValue(splitOptions.colorOffset.h ?? defaultOffset),
s: parentColor.s + getRangeValue(splitOptions.colorOffset.s ?? defaultOffset),
l: parentColor.l + getRangeValue(splitOptions.colorOffset.l ?? defaultOffset),
},

@@ -45,3 +46,3 @@ },

options.load(splitParticlesOptions);
const offset = splitOptions.sizeOffset ? setRangeValue(-parent.size.value, parent.size.value) : 0, position = {
const offset = splitOptions.sizeOffset ? setRangeValue(-parent.size.value, parent.size.value) : defaultOffset, position = {
x: parent.position.x + randomInRange(offset),

@@ -51,11 +52,11 @@ y: parent.position.y + randomInRange(offset),

return container.particles.addParticle(position, options, parent.group, (particle) => {
if (particle.size.value < 0.5) {
if (particle.size.value < minDestroySize) {
return false;
}
particle.velocity.length = randomInRange(setRangeValue(parent.velocity.length, particle.velocity.length));
particle.splitCount = (parent.splitCount ?? 0) + 1;
particle.splitCount = (parent.splitCount ?? defaultSplitCount) + increment;
particle.unbreakable = true;
setTimeout(() => {
particle.unbreakable = false;
}, 500);
}, unbreakableTime);
return true;

@@ -70,3 +71,4 @@ });

const splitOptions = destroyOptions.split;
if (splitOptions.count >= 0 && (particle.splitCount === undefined || particle.splitCount++ > splitOptions.count)) {
if (splitOptions.count >= minSplitCount &&
(particle.splitCount === undefined || particle.splitCount++ > splitOptions.count)) {
return;

@@ -73,0 +75,0 @@ }

@@ -9,4 +9,4 @@ "use strict";

constructor(engine, container) {
this.container = container;
this.engine = engine;
this.container = container;
}

@@ -25,12 +25,12 @@ init(particle) {

if (bottom) {
destroyBounds.bottom = ((0, engine_1.getRangeValue)(bottom) * canvasSize.height) / 100;
destroyBounds.bottom = ((0, engine_1.getRangeValue)(bottom) * canvasSize.height) / engine_1.percentDenominator;
}
if (left) {
destroyBounds.left = ((0, engine_1.getRangeValue)(left) * canvasSize.width) / 100;
destroyBounds.left = ((0, engine_1.getRangeValue)(left) * canvasSize.width) / engine_1.percentDenominator;
}
if (right) {
destroyBounds.right = ((0, engine_1.getRangeValue)(right) * canvasSize.width) / 100;
destroyBounds.right = ((0, engine_1.getRangeValue)(right) * canvasSize.width) / engine_1.percentDenominator;
}
if (top) {
destroyBounds.top = ((0, engine_1.getRangeValue)(top) * canvasSize.height) / 100;
destroyBounds.top = ((0, engine_1.getRangeValue)(top) * canvasSize.height) / engine_1.percentDenominator;
}

@@ -37,0 +37,0 @@ }

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

const engine_1 = require("@tsparticles/engine");
const defaultOffset = 0, minDestroySize = 0.5, defaultSplitCount = 0, increment = 1, unbreakableTime = 500, minSplitCount = 0;
function addSplitParticle(engine, container, parent, splitParticlesOptions) {

@@ -19,5 +20,5 @@ const destroyOptions = parent.options.destroy;

hsl: {
h: parentColor.h + (0, engine_1.getRangeValue)(splitOptions.colorOffset.h ?? 0),
s: parentColor.s + (0, engine_1.getRangeValue)(splitOptions.colorOffset.s ?? 0),
l: parentColor.l + (0, engine_1.getRangeValue)(splitOptions.colorOffset.l ?? 0),
h: parentColor.h + (0, engine_1.getRangeValue)(splitOptions.colorOffset.h ?? defaultOffset),
s: parentColor.s + (0, engine_1.getRangeValue)(splitOptions.colorOffset.s ?? defaultOffset),
l: parentColor.l + (0, engine_1.getRangeValue)(splitOptions.colorOffset.l ?? defaultOffset),
},

@@ -49,3 +50,3 @@ },

options.load(splitParticlesOptions);
const offset = splitOptions.sizeOffset ? (0, engine_1.setRangeValue)(-parent.size.value, parent.size.value) : 0, position = {
const offset = splitOptions.sizeOffset ? (0, engine_1.setRangeValue)(-parent.size.value, parent.size.value) : defaultOffset, position = {
x: parent.position.x + (0, engine_1.randomInRange)(offset),

@@ -55,11 +56,11 @@ y: parent.position.y + (0, engine_1.randomInRange)(offset),

return container.particles.addParticle(position, options, parent.group, (particle) => {
if (particle.size.value < 0.5) {
if (particle.size.value < minDestroySize) {
return false;
}
particle.velocity.length = (0, engine_1.randomInRange)((0, engine_1.setRangeValue)(parent.velocity.length, particle.velocity.length));
particle.splitCount = (parent.splitCount ?? 0) + 1;
particle.splitCount = (parent.splitCount ?? defaultSplitCount) + increment;
particle.unbreakable = true;
setTimeout(() => {
particle.unbreakable = false;
}, 500);
}, unbreakableTime);
return true;

@@ -74,3 +75,4 @@ });

const splitOptions = destroyOptions.split;
if (splitOptions.count >= 0 && (particle.splitCount === undefined || particle.splitCount++ > splitOptions.count)) {
if (splitOptions.count >= minSplitCount &&
(particle.splitCount === undefined || particle.splitCount++ > splitOptions.count)) {
return;

@@ -77,0 +79,0 @@ }

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

import { getRangeValue, } from "@tsparticles/engine";
import { getRangeValue, percentDenominator, } from "@tsparticles/engine";
import { Destroy } from "./Options/Classes/Destroy.js";

@@ -6,4 +6,4 @@ import { split } from "./Utils.js";

constructor(engine, container) {
this.container = container;
this.engine = engine;
this.container = container;
}

@@ -22,12 +22,12 @@ init(particle) {

if (bottom) {
destroyBounds.bottom = (getRangeValue(bottom) * canvasSize.height) / 100;
destroyBounds.bottom = (getRangeValue(bottom) * canvasSize.height) / percentDenominator;
}
if (left) {
destroyBounds.left = (getRangeValue(left) * canvasSize.width) / 100;
destroyBounds.left = (getRangeValue(left) * canvasSize.width) / percentDenominator;
}
if (right) {
destroyBounds.right = (getRangeValue(right) * canvasSize.width) / 100;
destroyBounds.right = (getRangeValue(right) * canvasSize.width) / percentDenominator;
}
if (top) {
destroyBounds.top = (getRangeValue(top) * canvasSize.height) / 100;
destroyBounds.top = (getRangeValue(top) * canvasSize.height) / percentDenominator;
}

@@ -34,0 +34,0 @@ }

import { getRangeValue, isNumber, itemFromSingleOrMultiple, loadParticlesOptions, randomInRange, setRangeValue, } from "@tsparticles/engine";
const defaultOffset = 0, minDestroySize = 0.5, defaultSplitCount = 0, increment = 1, unbreakableTime = 500, minSplitCount = 0;
function addSplitParticle(engine, container, parent, splitParticlesOptions) {

@@ -15,5 +16,5 @@ const destroyOptions = parent.options.destroy;

hsl: {
h: parentColor.h + getRangeValue(splitOptions.colorOffset.h ?? 0),
s: parentColor.s + getRangeValue(splitOptions.colorOffset.s ?? 0),
l: parentColor.l + getRangeValue(splitOptions.colorOffset.l ?? 0),
h: parentColor.h + getRangeValue(splitOptions.colorOffset.h ?? defaultOffset),
s: parentColor.s + getRangeValue(splitOptions.colorOffset.s ?? defaultOffset),
l: parentColor.l + getRangeValue(splitOptions.colorOffset.l ?? defaultOffset),
},

@@ -45,3 +46,3 @@ },

options.load(splitParticlesOptions);
const offset = splitOptions.sizeOffset ? setRangeValue(-parent.size.value, parent.size.value) : 0, position = {
const offset = splitOptions.sizeOffset ? setRangeValue(-parent.size.value, parent.size.value) : defaultOffset, position = {
x: parent.position.x + randomInRange(offset),

@@ -51,11 +52,11 @@ y: parent.position.y + randomInRange(offset),

return container.particles.addParticle(position, options, parent.group, (particle) => {
if (particle.size.value < 0.5) {
if (particle.size.value < minDestroySize) {
return false;
}
particle.velocity.length = randomInRange(setRangeValue(parent.velocity.length, particle.velocity.length));
particle.splitCount = (parent.splitCount ?? 0) + 1;
particle.splitCount = (parent.splitCount ?? defaultSplitCount) + increment;
particle.unbreakable = true;
setTimeout(() => {
particle.unbreakable = false;
}, 500);
}, unbreakableTime);
return true;

@@ -70,3 +71,4 @@ });

const splitOptions = destroyOptions.split;
if (splitOptions.count >= 0 && (particle.splitCount === undefined || particle.splitCount++ > splitOptions.count)) {
if (splitOptions.count >= minSplitCount &&
(particle.splitCount === undefined || particle.splitCount++ > splitOptions.count)) {
return;

@@ -73,0 +75,0 @@ }

{
"name": "@tsparticles/updater-destroy",
"version": "3.0.3",
"version": "3.1.0",
"description": "tsParticles particles destroy 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
*/

@@ -207,2 +207,8 @@ (function webpackUniversalModuleDefinition(root, factory) {

const defaultOffset = 0,
minDestroySize = 0.5,
defaultSplitCount = 0,
increment = 1,
unbreakableTime = 500,
minSplitCount = 0;
function addSplitParticle(engine, container, parent, splitParticlesOptions) {

@@ -223,5 +229,5 @@ const destroyOptions = parent.options.destroy;

hsl: {
h: parentColor.h + (0,engine_root_window_.getRangeValue)(splitOptions.colorOffset.h ?? 0),
s: parentColor.s + (0,engine_root_window_.getRangeValue)(splitOptions.colorOffset.s ?? 0),
l: parentColor.l + (0,engine_root_window_.getRangeValue)(splitOptions.colorOffset.l ?? 0)
h: parentColor.h + (0,engine_root_window_.getRangeValue)(splitOptions.colorOffset.h ?? defaultOffset),
s: parentColor.s + (0,engine_root_window_.getRangeValue)(splitOptions.colorOffset.s ?? defaultOffset),
l: parentColor.l + (0,engine_root_window_.getRangeValue)(splitOptions.colorOffset.l ?? defaultOffset)
}

@@ -251,3 +257,3 @@ }

options.load(splitParticlesOptions);
const offset = splitOptions.sizeOffset ? (0,engine_root_window_.setRangeValue)(-parent.size.value, parent.size.value) : 0,
const offset = splitOptions.sizeOffset ? (0,engine_root_window_.setRangeValue)(-parent.size.value, parent.size.value) : defaultOffset,
position = {

@@ -258,11 +264,11 @@ x: parent.position.x + (0,engine_root_window_.randomInRange)(offset),

return container.particles.addParticle(position, options, parent.group, particle => {
if (particle.size.value < 0.5) {
if (particle.size.value < minDestroySize) {
return false;
}
particle.velocity.length = (0,engine_root_window_.randomInRange)((0,engine_root_window_.setRangeValue)(parent.velocity.length, particle.velocity.length));
particle.splitCount = (parent.splitCount ?? 0) + 1;
particle.splitCount = (parent.splitCount ?? defaultSplitCount) + increment;
particle.unbreakable = true;
setTimeout(() => {
particle.unbreakable = false;
}, 500);
}, unbreakableTime);
return true;

@@ -277,3 +283,3 @@ });

const splitOptions = destroyOptions.split;
if (splitOptions.count >= 0 && (particle.splitCount === undefined || particle.splitCount++ > splitOptions.count)) {
if (splitOptions.count >= minSplitCount && (particle.splitCount === undefined || particle.splitCount++ > splitOptions.count)) {
return;

@@ -293,4 +299,4 @@ }

constructor(engine, container) {
this.container = container;
this.engine = engine;
this.container = container;
}

@@ -320,12 +326,12 @@ init(particle) {

if (bottom) {
destroyBounds.bottom = (0,engine_root_window_.getRangeValue)(bottom) * canvasSize.height / 100;
destroyBounds.bottom = (0,engine_root_window_.getRangeValue)(bottom) * canvasSize.height / engine_root_window_.percentDenominator;
}
if (left) {
destroyBounds.left = (0,engine_root_window_.getRangeValue)(left) * canvasSize.width / 100;
destroyBounds.left = (0,engine_root_window_.getRangeValue)(left) * canvasSize.width / engine_root_window_.percentDenominator;
}
if (right) {
destroyBounds.right = (0,engine_root_window_.getRangeValue)(right) * canvasSize.width / 100;
destroyBounds.right = (0,engine_root_window_.getRangeValue)(right) * canvasSize.width / engine_root_window_.percentDenominator;
}
if (top) {
destroyBounds.top = (0,engine_root_window_.getRangeValue)(top) * canvasSize.height / 100;
destroyBounds.top = (0,engine_root_window_.getRangeValue)(top) * canvasSize.height / engine_root_window_.percentDenominator;
}

@@ -332,0 +338,0 @@ }

/*! For license information please see tsparticles.updater.destroy.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 s in o)("object"==typeof exports?exports:t)[s]=o[s]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},o={};function s(t){var i=o[t];if(void 0!==i)return i.exports;var r=o[t]={exports:{}};return e[t](r,r.exports,s),r.exports}s.d=(t,e)=>{for(var o in e)s.o(e,o)&&!s.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{s.r(i),s.d(i,{loadDestroyUpdater:()=>d});var t=s(533);class e{load(e){e&&(void 0!==e.bottom&&(this.bottom=(0,t.setRangeValue)(e.bottom)),void 0!==e.left&&(this.left=(0,t.setRangeValue)(e.left)),void 0!==e.right&&(this.right=(0,t.setRangeValue)(e.right)),void 0!==e.top&&(this.top=(0,t.setRangeValue)(e.top)))}}class o extends t.ValueWithRandom{constructor(){super(),this.value=3}}class r extends t.ValueWithRandom{constructor(){super(),this.value={min:4,max:9}}}class n{constructor(){this.count=1,this.factor=new o,this.rate=new r,this.sizeOffset=!0}load(e){e&&(void 0!==e.color&&(this.color=t.OptionsColor.create(this.color,e.color)),void 0!==e.count&&(this.count=e.count),this.factor.load(e.factor),this.rate.load(e.rate),this.particles=(0,t.executeOnSingleOrMultiple)(e.particles,(e=>(0,t.deepExtend)({},e))),void 0!==e.sizeOffset&&(this.sizeOffset=e.sizeOffset),e.colorOffset&&(this.colorOffset=this.colorOffset??{},void 0!==e.colorOffset.h&&(this.colorOffset.h=e.colorOffset.h),void 0!==e.colorOffset.s&&(this.colorOffset.s=e.colorOffset.s),void 0!==e.colorOffset.l&&(this.colorOffset.l=e.colorOffset.l)))}}class l{constructor(){this.bounds=new e,this.mode="none",this.split=new n}load(t){t&&(t.mode&&(this.mode=t.mode),t.bounds&&this.bounds.load(t.bounds),this.split.load(t.split))}}function a(e,o,s,i){const r=s.options.destroy;if(!r)return;const n=r.split,l=(0,t.loadParticlesOptions)(e,o,s.options),a=(0,t.getRangeValue)(n.factor.value),c=s.getFillColor();n.color?l.color.load(n.color):n.colorOffset&&c?l.color.load({value:{hsl:{h:c.h+(0,t.getRangeValue)(n.colorOffset.h??0),s:c.s+(0,t.getRangeValue)(n.colorOffset.s??0),l:c.l+(0,t.getRangeValue)(n.colorOffset.l??0)}}}):l.color.load({value:{hsl:s.getFillColor()}}),l.move.load({center:{x:s.position.x,y:s.position.y,mode:"precise"}}),(0,t.isNumber)(l.size.value)?l.size.value/=a:(l.size.value.min/=a,l.size.value.max/=a),l.load(i);const d=n.sizeOffset?(0,t.setRangeValue)(-s.size.value,s.size.value):0,u={x:s.position.x+(0,t.randomInRange)(d),y:s.position.y+(0,t.randomInRange)(d)};return o.particles.addParticle(u,l,s.group,(e=>!(e.size.value<.5)&&(e.velocity.length=(0,t.randomInRange)((0,t.setRangeValue)(s.velocity.length,e.velocity.length)),e.splitCount=(s.splitCount??0)+1,e.unbreakable=!0,setTimeout((()=>{e.unbreakable=!1}),500),!0)))}class c{constructor(t,e){this.engine=t,this.container=e}init(e){const o=this.container,s=e.options.destroy;if(!s)return;e.splitCount=0;const i=s.bounds;e.destroyBounds||(e.destroyBounds={});const{bottom:r,left:n,right:l,top:a}=i,{destroyBounds:c}=e,d=o.canvas.size;r&&(c.bottom=(0,t.getRangeValue)(r)*d.height/100),n&&(c.left=(0,t.getRangeValue)(n)*d.width/100),l&&(c.right=(0,t.getRangeValue)(l)*d.width/100),a&&(c.top=(0,t.getRangeValue)(a)*d.height/100)}isEnabled(t){return!t.destroyed}loadOptions(t,...e){t.destroy||(t.destroy=new l);for(const o of e)t.destroy.load(o?.destroy)}particleDestroyed(e,o){if(o)return;const s=e.options.destroy;s&&"split"===s.mode&&function(e,o,s){const i=s.options.destroy;if(!i)return;const r=i.split;if(r.count>=0&&(void 0===s.splitCount||s.splitCount++>r.count))return;const n=(0,t.getRangeValue)(r.rate.value),l=(0,t.itemFromSingleOrMultiple)(r.particles);for(let t=0;t<n;t++)a(e,o,s,l)}(this.engine,this.container,e)}update(t){if(!this.isEnabled(t))return;const e=t.getPosition(),o=t.destroyBounds;o&&(void 0!==o.bottom&&e.y>=o.bottom||void 0!==o.left&&e.x<=o.left||void 0!==o.right&&e.x>=o.right||void 0!==o.top&&e.y<=o.top)&&t.destroy()}}async function d(t,e=!0){await t.addParticleUpdater("destroy",(e=>new c(t,e)),e)}})(),i})()));
!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 s in o)("object"==typeof exports?exports:t)[s]=o[s]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},o={};function s(t){var i=o[t];if(void 0!==i)return i.exports;var r=o[t]={exports:{}};return e[t](r,r.exports,s),r.exports}s.d=(t,e)=>{for(var o in e)s.o(e,o)&&!s.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{s.r(i),s.d(i,{loadDestroyUpdater:()=>g});var t=s(533);class e{load(e){e&&(void 0!==e.bottom&&(this.bottom=(0,t.setRangeValue)(e.bottom)),void 0!==e.left&&(this.left=(0,t.setRangeValue)(e.left)),void 0!==e.right&&(this.right=(0,t.setRangeValue)(e.right)),void 0!==e.top&&(this.top=(0,t.setRangeValue)(e.top)))}}class o extends t.ValueWithRandom{constructor(){super(),this.value=3}}class r extends t.ValueWithRandom{constructor(){super(),this.value={min:4,max:9}}}class n{constructor(){this.count=1,this.factor=new o,this.rate=new r,this.sizeOffset=!0}load(e){e&&(void 0!==e.color&&(this.color=t.OptionsColor.create(this.color,e.color)),void 0!==e.count&&(this.count=e.count),this.factor.load(e.factor),this.rate.load(e.rate),this.particles=(0,t.executeOnSingleOrMultiple)(e.particles,(e=>(0,t.deepExtend)({},e))),void 0!==e.sizeOffset&&(this.sizeOffset=e.sizeOffset),e.colorOffset&&(this.colorOffset=this.colorOffset??{},void 0!==e.colorOffset.h&&(this.colorOffset.h=e.colorOffset.h),void 0!==e.colorOffset.s&&(this.colorOffset.s=e.colorOffset.s),void 0!==e.colorOffset.l&&(this.colorOffset.l=e.colorOffset.l)))}}class l{constructor(){this.bounds=new e,this.mode="none",this.split=new n}load(t){t&&(t.mode&&(this.mode=t.mode),t.bounds&&this.bounds.load(t.bounds),this.split.load(t.split))}}const a=0,c=.5,d=0,u=1,f=500;function p(e,o,s,i){const r=s.options.destroy;if(!r)return;const n=r.split,l=(0,t.loadParticlesOptions)(e,o,s.options),p=(0,t.getRangeValue)(n.factor.value),h=s.getFillColor();n.color?l.color.load(n.color):n.colorOffset&&h?l.color.load({value:{hsl:{h:h.h+(0,t.getRangeValue)(n.colorOffset.h??a),s:h.s+(0,t.getRangeValue)(n.colorOffset.s??a),l:h.l+(0,t.getRangeValue)(n.colorOffset.l??a)}}}):l.color.load({value:{hsl:s.getFillColor()}}),l.move.load({center:{x:s.position.x,y:s.position.y,mode:"precise"}}),(0,t.isNumber)(l.size.value)?l.size.value/=p:(l.size.value.min/=p,l.size.value.max/=p),l.load(i);const g=n.sizeOffset?(0,t.setRangeValue)(-s.size.value,s.size.value):a,v={x:s.position.x+(0,t.randomInRange)(g),y:s.position.y+(0,t.randomInRange)(g)};return o.particles.addParticle(v,l,s.group,(e=>!(e.size.value<c)&&(e.velocity.length=(0,t.randomInRange)((0,t.setRangeValue)(s.velocity.length,e.velocity.length)),e.splitCount=(s.splitCount??d)+u,e.unbreakable=!0,setTimeout((()=>{e.unbreakable=!1}),f),!0)))}class h{constructor(t,e){this.container=e,this.engine=t}init(e){const o=this.container,s=e.options.destroy;if(!s)return;e.splitCount=0;const i=s.bounds;e.destroyBounds||(e.destroyBounds={});const{bottom:r,left:n,right:l,top:a}=i,{destroyBounds:c}=e,d=o.canvas.size;r&&(c.bottom=(0,t.getRangeValue)(r)*d.height/t.percentDenominator),n&&(c.left=(0,t.getRangeValue)(n)*d.width/t.percentDenominator),l&&(c.right=(0,t.getRangeValue)(l)*d.width/t.percentDenominator),a&&(c.top=(0,t.getRangeValue)(a)*d.height/t.percentDenominator)}isEnabled(t){return!t.destroyed}loadOptions(t,...e){t.destroy||(t.destroy=new l);for(const o of e)t.destroy.load(o?.destroy)}particleDestroyed(e,o){if(o)return;const s=e.options.destroy;s&&"split"===s.mode&&function(e,o,s){const i=s.options.destroy;if(!i)return;const r=i.split;if(r.count>=0&&(void 0===s.splitCount||s.splitCount++>r.count))return;const n=(0,t.getRangeValue)(r.rate.value),l=(0,t.itemFromSingleOrMultiple)(r.particles);for(let t=0;t<n;t++)p(e,o,s,l)}(this.engine,this.container,e)}update(t){if(!this.isEnabled(t))return;const e=t.getPosition(),o=t.destroyBounds;o&&(void 0!==o.bottom&&e.y>=o.bottom||void 0!==o.left&&e.x<=o.left||void 0!==o.right&&e.x>=o.right||void 0!==o.top&&e.y<=o.top)&&t.destroy()}}async function g(t,e=!0){await t.addParticleUpdater("destroy",(e=>new h(t,e)),e)}})(),i})()));

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

/*! tsParticles Destroy Updater v3.0.3 by Matteo Bruni */
/*! tsParticles Destroy Updater v3.1.0 by Matteo Bruni */
import { type Container, type Engine, type IParticleUpdater, type Particle, type RecursivePartial } from "@tsparticles/engine";
import type { DestroyParticle, DestroyParticlesOptions, IDestroyParticlesOptions } from "./Types.js";
export declare class DestroyUpdater implements IParticleUpdater {
private readonly container;
private readonly engine;
private readonly container;
constructor(engine: Engine, container: Container);

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

@@ -18,4 +18,4 @@ (function (factory) {

constructor(engine, container) {
this.container = container;
this.engine = engine;
this.container = container;
}

@@ -34,12 +34,12 @@ init(particle) {

if (bottom) {
destroyBounds.bottom = ((0, engine_1.getRangeValue)(bottom) * canvasSize.height) / 100;
destroyBounds.bottom = ((0, engine_1.getRangeValue)(bottom) * canvasSize.height) / engine_1.percentDenominator;
}
if (left) {
destroyBounds.left = ((0, engine_1.getRangeValue)(left) * canvasSize.width) / 100;
destroyBounds.left = ((0, engine_1.getRangeValue)(left) * canvasSize.width) / engine_1.percentDenominator;
}
if (right) {
destroyBounds.right = ((0, engine_1.getRangeValue)(right) * canvasSize.width) / 100;
destroyBounds.right = ((0, engine_1.getRangeValue)(right) * canvasSize.width) / engine_1.percentDenominator;
}
if (top) {
destroyBounds.top = ((0, engine_1.getRangeValue)(top) * canvasSize.height) / 100;
destroyBounds.top = ((0, engine_1.getRangeValue)(top) * canvasSize.height) / engine_1.percentDenominator;
}

@@ -46,0 +46,0 @@ }

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

const engine_1 = require("@tsparticles/engine");
const defaultOffset = 0, minDestroySize = 0.5, defaultSplitCount = 0, increment = 1, unbreakableTime = 500, minSplitCount = 0;
function addSplitParticle(engine, container, parent, splitParticlesOptions) {

@@ -28,5 +29,5 @@ const destroyOptions = parent.options.destroy;

hsl: {
h: parentColor.h + (0, engine_1.getRangeValue)(splitOptions.colorOffset.h ?? 0),
s: parentColor.s + (0, engine_1.getRangeValue)(splitOptions.colorOffset.s ?? 0),
l: parentColor.l + (0, engine_1.getRangeValue)(splitOptions.colorOffset.l ?? 0),
h: parentColor.h + (0, engine_1.getRangeValue)(splitOptions.colorOffset.h ?? defaultOffset),
s: parentColor.s + (0, engine_1.getRangeValue)(splitOptions.colorOffset.s ?? defaultOffset),
l: parentColor.l + (0, engine_1.getRangeValue)(splitOptions.colorOffset.l ?? defaultOffset),
},

@@ -58,3 +59,3 @@ },

options.load(splitParticlesOptions);
const offset = splitOptions.sizeOffset ? (0, engine_1.setRangeValue)(-parent.size.value, parent.size.value) : 0, position = {
const offset = splitOptions.sizeOffset ? (0, engine_1.setRangeValue)(-parent.size.value, parent.size.value) : defaultOffset, position = {
x: parent.position.x + (0, engine_1.randomInRange)(offset),

@@ -64,11 +65,11 @@ y: parent.position.y + (0, engine_1.randomInRange)(offset),

return container.particles.addParticle(position, options, parent.group, (particle) => {
if (particle.size.value < 0.5) {
if (particle.size.value < minDestroySize) {
return false;
}
particle.velocity.length = (0, engine_1.randomInRange)((0, engine_1.setRangeValue)(parent.velocity.length, particle.velocity.length));
particle.splitCount = (parent.splitCount ?? 0) + 1;
particle.splitCount = (parent.splitCount ?? defaultSplitCount) + increment;
particle.unbreakable = true;
setTimeout(() => {
particle.unbreakable = false;
}, 500);
}, unbreakableTime);
return true;

@@ -83,3 +84,4 @@ });

const splitOptions = destroyOptions.split;
if (splitOptions.count >= 0 && (particle.splitCount === undefined || particle.splitCount++ > splitOptions.count)) {
if (splitOptions.count >= minSplitCount &&
(particle.splitCount === undefined || particle.splitCount++ > splitOptions.count)) {
return;

@@ -86,0 +88,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