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

@tsparticles/updater-size

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tsparticles/updater-size - npm Package Compare versions

Comparing version 3.0.0-alpha.1 to 3.0.0-beta.0

browser/Utils.js

4

browser/index.js
import { SizeUpdater } from "./SizeUpdater";
export async function loadSizeUpdater(engine) {
await engine.addParticleUpdater("size", () => new SizeUpdater());
export async function loadSizeUpdater(engine, refresh = true) {
await engine.addParticleUpdater("size", () => new SizeUpdater(), refresh);
}

@@ -1,64 +0,9 @@

import { clamp, getRandom } from "@tsparticles/engine";
function checkDestroy(particle, value, minValue, maxValue) {
switch (particle.options.size.animation.destroy) {
case "max":
if (value >= maxValue) {
particle.destroy();
}
break;
case "min":
if (value <= minValue) {
particle.destroy();
}
break;
}
}
function updateSize(particle, delta) {
var _a, _b, _c, _d, _e;
const sizeVelocity = ((_a = particle.size.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor, minValue = particle.size.min, maxValue = particle.size.max, decay = (_b = particle.size.decay) !== null && _b !== void 0 ? _b : 1;
if (particle.destroyed ||
!particle.size.enable ||
(((_c = particle.size.maxLoops) !== null && _c !== void 0 ? _c : 0) > 0 && ((_d = particle.size.loops) !== null && _d !== void 0 ? _d : 0) > ((_e = particle.size.maxLoops) !== null && _e !== void 0 ? _e : 0))) {
return;
}
switch (particle.size.status) {
case "increasing":
if (particle.size.value >= maxValue) {
particle.size.status = "decreasing";
if (!particle.size.loops) {
particle.size.loops = 0;
}
particle.size.loops++;
}
else {
particle.size.value += sizeVelocity;
}
break;
case "decreasing":
if (particle.size.value <= minValue) {
particle.size.status = "increasing";
if (!particle.size.loops) {
particle.size.loops = 0;
}
particle.size.loops++;
}
else {
particle.size.value -= sizeVelocity;
}
}
if (particle.size.velocity && decay !== 1) {
particle.size.velocity *= decay;
}
checkDestroy(particle, particle.size.value, minValue, maxValue);
if (!particle.destroyed) {
particle.size.value = clamp(particle.size.value, minValue, maxValue);
}
}
import { getRandom } from "@tsparticles/engine";
import { updateSize } from "./Utils";
export class SizeUpdater {
init(particle) {
var _a;
const container = particle.container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
if (sizeAnimation.enable) {
particle.size.velocity =
(((_a = particle.retina.sizeAnimationSpeed) !== null && _a !== void 0 ? _a : container.retina.sizeAnimationSpeed) / 100) *
((particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / 100) *
container.retina.reduceFactor;

@@ -71,8 +16,7 @@ if (!sizeAnimation.sync) {

isEnabled(particle) {
var _a, _b, _c, _d;
return (!particle.destroyed &&
!particle.spawning &&
particle.size.enable &&
(((_a = particle.size.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 ||
(((_b = particle.size.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.size.loops) !== null && _c !== void 0 ? _c : 0) < ((_d = particle.size.maxLoops) !== null && _d !== void 0 ? _d : 0))));
((particle.size.maxLoops ?? 0) <= 0 ||
((particle.size.maxLoops ?? 0) > 0 && (particle.size.loops ?? 0) < (particle.size.maxLoops ?? 0))));
}

@@ -79,0 +23,0 @@ reset(particle) {

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadSizeUpdater = void 0;
const SizeUpdater_1 = require("./SizeUpdater");
function loadSizeUpdater(engine) {
return __awaiter(this, void 0, void 0, function* () {
yield engine.addParticleUpdater("size", () => new SizeUpdater_1.SizeUpdater());
});
async function loadSizeUpdater(engine, refresh = true) {
await engine.addParticleUpdater("size", () => new SizeUpdater_1.SizeUpdater(), refresh);
}
exports.loadSizeUpdater = loadSizeUpdater;

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

const engine_1 = require("@tsparticles/engine");
function checkDestroy(particle, value, minValue, maxValue) {
switch (particle.options.size.animation.destroy) {
case "max":
if (value >= maxValue) {
particle.destroy();
}
break;
case "min":
if (value <= minValue) {
particle.destroy();
}
break;
}
}
function updateSize(particle, delta) {
var _a, _b, _c, _d, _e;
const sizeVelocity = ((_a = particle.size.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor, minValue = particle.size.min, maxValue = particle.size.max, decay = (_b = particle.size.decay) !== null && _b !== void 0 ? _b : 1;
if (particle.destroyed ||
!particle.size.enable ||
(((_c = particle.size.maxLoops) !== null && _c !== void 0 ? _c : 0) > 0 && ((_d = particle.size.loops) !== null && _d !== void 0 ? _d : 0) > ((_e = particle.size.maxLoops) !== null && _e !== void 0 ? _e : 0))) {
return;
}
switch (particle.size.status) {
case "increasing":
if (particle.size.value >= maxValue) {
particle.size.status = "decreasing";
if (!particle.size.loops) {
particle.size.loops = 0;
}
particle.size.loops++;
}
else {
particle.size.value += sizeVelocity;
}
break;
case "decreasing":
if (particle.size.value <= minValue) {
particle.size.status = "increasing";
if (!particle.size.loops) {
particle.size.loops = 0;
}
particle.size.loops++;
}
else {
particle.size.value -= sizeVelocity;
}
}
if (particle.size.velocity && decay !== 1) {
particle.size.velocity *= decay;
}
checkDestroy(particle, particle.size.value, minValue, maxValue);
if (!particle.destroyed) {
particle.size.value = (0, engine_1.clamp)(particle.size.value, minValue, maxValue);
}
}
const Utils_1 = require("./Utils");
class SizeUpdater {
init(particle) {
var _a;
const container = particle.container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
if (sizeAnimation.enable) {
particle.size.velocity =
(((_a = particle.retina.sizeAnimationSpeed) !== null && _a !== void 0 ? _a : container.retina.sizeAnimationSpeed) / 100) *
((particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / 100) *
container.retina.reduceFactor;

@@ -75,8 +20,7 @@ if (!sizeAnimation.sync) {

isEnabled(particle) {
var _a, _b, _c, _d;
return (!particle.destroyed &&
!particle.spawning &&
particle.size.enable &&
(((_a = particle.size.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 ||
(((_b = particle.size.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.size.loops) !== null && _c !== void 0 ? _c : 0) < ((_d = particle.size.maxLoops) !== null && _d !== void 0 ? _d : 0))));
((particle.size.maxLoops ?? 0) <= 0 ||
((particle.size.maxLoops ?? 0) > 0 && (particle.size.loops ?? 0) < (particle.size.maxLoops ?? 0))));
}

@@ -90,5 +34,5 @@ reset(particle) {

}
updateSize(particle, delta);
(0, Utils_1.updateSize)(particle, delta);
}
}
exports.SizeUpdater = SizeUpdater;
import { SizeUpdater } from "./SizeUpdater";
export async function loadSizeUpdater(engine) {
await engine.addParticleUpdater("size", () => new SizeUpdater());
export async function loadSizeUpdater(engine, refresh = true) {
await engine.addParticleUpdater("size", () => new SizeUpdater(), refresh);
}

@@ -1,64 +0,9 @@

import { clamp, getRandom } from "@tsparticles/engine";
function checkDestroy(particle, value, minValue, maxValue) {
switch (particle.options.size.animation.destroy) {
case "max":
if (value >= maxValue) {
particle.destroy();
}
break;
case "min":
if (value <= minValue) {
particle.destroy();
}
break;
}
}
function updateSize(particle, delta) {
var _a, _b, _c, _d, _e;
const sizeVelocity = ((_a = particle.size.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor, minValue = particle.size.min, maxValue = particle.size.max, decay = (_b = particle.size.decay) !== null && _b !== void 0 ? _b : 1;
if (particle.destroyed ||
!particle.size.enable ||
(((_c = particle.size.maxLoops) !== null && _c !== void 0 ? _c : 0) > 0 && ((_d = particle.size.loops) !== null && _d !== void 0 ? _d : 0) > ((_e = particle.size.maxLoops) !== null && _e !== void 0 ? _e : 0))) {
return;
}
switch (particle.size.status) {
case "increasing":
if (particle.size.value >= maxValue) {
particle.size.status = "decreasing";
if (!particle.size.loops) {
particle.size.loops = 0;
}
particle.size.loops++;
}
else {
particle.size.value += sizeVelocity;
}
break;
case "decreasing":
if (particle.size.value <= minValue) {
particle.size.status = "increasing";
if (!particle.size.loops) {
particle.size.loops = 0;
}
particle.size.loops++;
}
else {
particle.size.value -= sizeVelocity;
}
}
if (particle.size.velocity && decay !== 1) {
particle.size.velocity *= decay;
}
checkDestroy(particle, particle.size.value, minValue, maxValue);
if (!particle.destroyed) {
particle.size.value = clamp(particle.size.value, minValue, maxValue);
}
}
import { getRandom } from "@tsparticles/engine";
import { updateSize } from "./Utils";
export class SizeUpdater {
init(particle) {
var _a;
const container = particle.container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
if (sizeAnimation.enable) {
particle.size.velocity =
(((_a = particle.retina.sizeAnimationSpeed) !== null && _a !== void 0 ? _a : container.retina.sizeAnimationSpeed) / 100) *
((particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / 100) *
container.retina.reduceFactor;

@@ -71,8 +16,7 @@ if (!sizeAnimation.sync) {

isEnabled(particle) {
var _a, _b, _c, _d;
return (!particle.destroyed &&
!particle.spawning &&
particle.size.enable &&
(((_a = particle.size.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 ||
(((_b = particle.size.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.size.loops) !== null && _c !== void 0 ? _c : 0) < ((_d = particle.size.maxLoops) !== null && _d !== void 0 ? _d : 0))));
((particle.size.maxLoops ?? 0) <= 0 ||
((particle.size.maxLoops ?? 0) > 0 && (particle.size.loops ?? 0) < (particle.size.maxLoops ?? 0))));
}

@@ -79,0 +23,0 @@ reset(particle) {

{
"name": "@tsparticles/updater-size",
"version": "3.0.0-alpha.1",
"version": "3.0.0-beta.0",
"description": "tsParticles particles size updater",

@@ -76,8 +76,9 @@ "homepage": "https://particles.js.org",

"types": "types/index.d.ts",
"sideEffects": false,
"dependencies": {
"@tsparticles/engine": "^3.0.0-beta.0"
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@tsparticles/engine": "^3.0.0-alpha.1"
}
}
}

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

[![jsDelivr](https://data.jsdelivr.com/v1/package/npm/tsparticles-updater-size/badge)](https://www.jsdelivr.com/package/npm/tsparticles-updater-size)
[![npmjs](https://badge.fury.io/js/tsparticles-updater-size.svg)](https://www.npmjs.com/package/tsparticles-updater-size)
[![npmjs](https://img.shields.io/npm/dt/tsparticles-updater-size)](https://www.npmjs.com/package/tsparticles-updater-size) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
[![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/updater-size/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/updater-size)
[![npmjs](https://badge.fury.io/js/@tsparticles/updater-size.svg)](https://www.npmjs.com/package/@tsparticles/updater-size)
[![npmjs](https://img.shields.io/npm/dt/@tsparticles/updater-size)](https://www.npmjs.com/package/@tsparticles/updater-size) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)

@@ -30,3 +30,3 @@ [tsParticles](https://github.com/matteobruni/tsparticles) updater plugin for size animations.

(async () => {
await loadSizeUpdater();
await loadSizeUpdater(tsParticles);

@@ -47,3 +47,3 @@ await tsParticles.load({

```shell
$ npm install tsparticles-updater-size
$ npm install @tsparticles/updater-size
```

@@ -54,3 +54,3 @@

```shell
$ yarn add tsparticles-updater-size
$ yarn add @tsparticles/updater-size
```

@@ -61,6 +61,8 @@

```javascript
const { tsParticles } = require("tsparticles-engine");
const { loadSizeUpdater } = require("tsparticles-updater-size");
const { tsParticles } = require("@tsparticles/engine");
const { loadSizeUpdater } = require("@tsparticles/updater-size");
loadSizeUpdater(tsParticles);
(async () => {
await loadSizeUpdater(tsParticles);
})();
```

@@ -71,6 +73,8 @@

```javascript
import { tsParticles } from "tsparticles-engine";
import { loadSizeUpdater } from "tsparticles-updater-size";
import { tsParticles } from "@tsparticles/engine";
import { loadSizeUpdater } from "@tsparticles/updater-size";
loadSizeUpdater(tsParticles);
(async () => {
await loadSizeUpdater(tsParticles);
})();
```

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

* How to use? : Check the GitHub README
* v3.0.0-alpha.1
* v3.0.0-beta.0
*/

@@ -95,3 +95,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

__webpack_require__.d(__webpack_exports__, {
"loadSizeUpdater": () => (/* binding */ loadSizeUpdater)
loadSizeUpdater: () => (/* binding */ loadSizeUpdater)
});

@@ -101,3 +101,3 @@

var engine_root_window_ = __webpack_require__(533);
;// CONCATENATED MODULE: ./dist/browser/SizeUpdater.js
;// CONCATENATED MODULE: ./dist/browser/Utils.js

@@ -119,44 +119,55 @@ function checkDestroy(particle, value, minValue, maxValue) {

function updateSize(particle, delta) {
var _a, _b, _c, _d, _e;
const sizeVelocity = ((_a = particle.size.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor,
minValue = particle.size.min,
maxValue = particle.size.max,
decay = (_b = particle.size.decay) !== null && _b !== void 0 ? _b : 1;
if (particle.destroyed || !particle.size.enable || ((_c = particle.size.maxLoops) !== null && _c !== void 0 ? _c : 0) > 0 && ((_d = particle.size.loops) !== null && _d !== void 0 ? _d : 0) > ((_e = particle.size.maxLoops) !== null && _e !== void 0 ? _e : 0)) {
const data = particle.size;
if (particle.destroyed || !data || !data.enable || (data.maxLoops ?? 0) > 0 && (data.loops ?? 0) > (data.maxLoops ?? 0)) {
return;
}
switch (particle.size.status) {
const sizeVelocity = (data.velocity ?? 0) * delta.factor,
minValue = data.min,
maxValue = data.max,
decay = data.decay ?? 1;
if (!data.time) {
data.time = 0;
}
if ((data.delayTime ?? 0) > 0 && data.time < (data.delayTime ?? 0)) {
data.time += delta.value;
}
if ((data.delayTime ?? 0) > 0 && data.time < (data.delayTime ?? 0)) {
return;
}
switch (data.status) {
case "increasing":
if (particle.size.value >= maxValue) {
particle.size.status = "decreasing";
if (!particle.size.loops) {
particle.size.loops = 0;
if (data.value >= maxValue) {
data.status = "decreasing";
if (!data.loops) {
data.loops = 0;
}
particle.size.loops++;
data.loops++;
} else {
particle.size.value += sizeVelocity;
data.value += sizeVelocity;
}
break;
case "decreasing":
if (particle.size.value <= minValue) {
particle.size.status = "increasing";
if (!particle.size.loops) {
particle.size.loops = 0;
if (data.value <= minValue) {
data.status = "increasing";
if (!data.loops) {
data.loops = 0;
}
particle.size.loops++;
data.loops++;
} else {
particle.size.value -= sizeVelocity;
data.value -= sizeVelocity;
}
}
if (particle.size.velocity && decay !== 1) {
particle.size.velocity *= decay;
if (data.velocity && decay !== 1) {
data.velocity *= decay;
}
checkDestroy(particle, particle.size.value, minValue, maxValue);
checkDestroy(particle, data.value, minValue, maxValue);
if (!particle.destroyed) {
particle.size.value = (0,engine_root_window_.clamp)(particle.size.value, minValue, maxValue);
data.value = (0,engine_root_window_.clamp)(data.value, minValue, maxValue);
}
}
;// CONCATENATED MODULE: ./dist/browser/SizeUpdater.js
class SizeUpdater {
init(particle) {
var _a;
const container = particle.container,

@@ -166,3 +177,3 @@ sizeOptions = particle.options.size,

if (sizeAnimation.enable) {
particle.size.velocity = ((_a = particle.retina.sizeAnimationSpeed) !== null && _a !== void 0 ? _a : container.retina.sizeAnimationSpeed) / 100 * container.retina.reduceFactor;
particle.size.velocity = (particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / 100 * container.retina.reduceFactor;
if (!sizeAnimation.sync) {

@@ -174,4 +185,3 @@ particle.size.velocity *= (0,engine_root_window_.getRandom)();

isEnabled(particle) {
var _a, _b, _c, _d;
return !particle.destroyed && !particle.spawning && particle.size.enable && (((_a = particle.size.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 || ((_b = particle.size.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.size.loops) !== null && _c !== void 0 ? _c : 0) < ((_d = particle.size.maxLoops) !== null && _d !== void 0 ? _d : 0));
return !particle.destroyed && !particle.spawning && particle.size.enable && ((particle.size.maxLoops ?? 0) <= 0 || (particle.size.maxLoops ?? 0) > 0 && (particle.size.loops ?? 0) < (particle.size.maxLoops ?? 0));
}

@@ -190,4 +200,4 @@ reset(particle) {

async function loadSizeUpdater(engine) {
await engine.addParticleUpdater("size", () => new SizeUpdater());
async function loadSizeUpdater(engine, refresh = true) {
await engine.addParticleUpdater("size", () => new SizeUpdater(), refresh);
}

@@ -194,0 +204,0 @@ })();

/*! For license information please see tsparticles.updater.size.min.js.LICENSE.txt */
!function(e,i){if("object"==typeof exports&&"object"==typeof module)module.exports=i(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],i);else{var o="object"==typeof exports?i(require("@tsparticles/engine")):i(e.window);for(var s in o)("object"==typeof exports?exports:e)[s]=o[s]}}(this,(e=>(()=>{"use strict";var i={533:i=>{i.exports=e}},o={};function s(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return i[e](n,n.exports,s),n.exports}s.d=(e,i)=>{for(var o in i)s.o(i,o)&&!s.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:i[o]})},s.o=(e,i)=>Object.prototype.hasOwnProperty.call(e,i),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};return(()=>{s.r(t),s.d(t,{loadSizeUpdater:()=>o});var e=s(533);class i{init(i){var o;const s=i.container,t=i.options.size.animation;t.enable&&(i.size.velocity=(null!==(o=i.retina.sizeAnimationSpeed)&&void 0!==o?o:s.retina.sizeAnimationSpeed)/100*s.retina.reduceFactor,t.sync||(i.size.velocity*=(0,e.getRandom)()))}isEnabled(e){var i,o,s,t;return!e.destroyed&&!e.spawning&&e.size.enable&&((null!==(i=e.size.maxLoops)&&void 0!==i?i:0)<=0||(null!==(o=e.size.maxLoops)&&void 0!==o?o:0)>0&&(null!==(s=e.size.loops)&&void 0!==s?s:0)<(null!==(t=e.size.maxLoops)&&void 0!==t?t:0))}reset(e){e.size.loops=0}update(i,o){this.isEnabled(i)&&function(i,o){var s,t,n,a,r;const l=(null!==(s=i.size.velocity)&&void 0!==s?s:0)*o.factor,d=i.size.min,p=i.size.max,c=null!==(t=i.size.decay)&&void 0!==t?t:1;if(!(i.destroyed||!i.size.enable||(null!==(n=i.size.maxLoops)&&void 0!==n?n:0)>0&&(null!==(a=i.size.loops)&&void 0!==a?a:0)>(null!==(r=i.size.maxLoops)&&void 0!==r?r:0))){switch(i.size.status){case"increasing":i.size.value>=p?(i.size.status="decreasing",i.size.loops||(i.size.loops=0),i.size.loops++):i.size.value+=l;break;case"decreasing":i.size.value<=d?(i.size.status="increasing",i.size.loops||(i.size.loops=0),i.size.loops++):i.size.value-=l}i.size.velocity&&1!==c&&(i.size.velocity*=c),function(e,i,o,s){switch(e.options.size.animation.destroy){case"max":i>=s&&e.destroy();break;case"min":i<=o&&e.destroy()}}(i,i.size.value,d,p),i.destroyed||(i.size.value=(0,e.clamp)(i.size.value,d,p))}}(i,o)}}async function o(e){await e.addParticleUpdater("size",(()=>new i))}})(),t})()));
!function(e,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 t="object"==typeof exports?o(require("@tsparticles/engine")):o(e.window);for(var i in t)("object"==typeof exports?exports:e)[i]=t[i]}}(this,(e=>(()=>{"use strict";var o={533:o=>{o.exports=e}},t={};function i(e){var s=t[e];if(void 0!==s)return s.exports;var a=t[e]={exports:{}};return o[e](a,a.exports,i),a.exports}i.d=(e,o)=>{for(var t in o)i.o(o,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:o[t]})},i.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return(()=>{i.r(s),i.d(s,{loadSizeUpdater:()=>t});var e=i(533);class o{init(o){const t=o.container,i=o.options.size.animation;i.enable&&(o.size.velocity=(o.retina.sizeAnimationSpeed??t.retina.sizeAnimationSpeed)/100*t.retina.reduceFactor,i.sync||(o.size.velocity*=(0,e.getRandom)()))}isEnabled(e){return!e.destroyed&&!e.spawning&&e.size.enable&&((e.size.maxLoops??0)<=0||(e.size.maxLoops??0)>0&&(e.size.loops??0)<(e.size.maxLoops??0))}reset(e){e.size.loops=0}update(o,t){this.isEnabled(o)&&function(o,t){const i=o.size;if(o.destroyed||!i||!i.enable||(i.maxLoops??0)>0&&(i.loops??0)>(i.maxLoops??0))return;const s=(i.velocity??0)*t.factor,a=i.min,n=i.max,r=i.decay??1;if(i.time||(i.time=0),(i.delayTime??0)>0&&i.time<(i.delayTime??0)&&(i.time+=t.value),!((i.delayTime??0)>0&&i.time<(i.delayTime??0))){switch(i.status){case"increasing":i.value>=n?(i.status="decreasing",i.loops||(i.loops=0),i.loops++):i.value+=s;break;case"decreasing":i.value<=a?(i.status="increasing",i.loops||(i.loops=0),i.loops++):i.value-=s}i.velocity&&1!==r&&(i.velocity*=r),function(e,o,t,i){switch(e.options.size.animation.destroy){case"max":o>=i&&e.destroy();break;case"min":o<=t&&e.destroy()}}(o,i.value,a,n),o.destroyed||(i.value=(0,e.clamp)(i.value,a,n))}}(o,t)}}async function t(e,t=!0){await e.addParticleUpdater("size",(()=>new o),t)}})(),s})()));

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

/*!
* Author : Matteo Bruni
* MIT license: https://opensource.org/licenses/MIT
* Demo / Generator : https://particles.js.org/
* GitHub : https://www.github.com/matteobruni/tsparticles
* How to use? : Check the GitHub README
* v3.0.0-alpha.1
*/
/*! tsParticles Size Updater v3.0.0-beta.0 by Matteo Bruni */
import type { Engine } from "@tsparticles/engine";
export declare function loadSizeUpdater(engine: Engine): Promise<void>;
export declare function loadSizeUpdater(engine: Engine, refresh?: boolean): Promise<void>;

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

import type { IDelta, IParticleUpdater, Particle } from "@tsparticles/engine";
import { type IDelta, type IParticleUpdater, type Particle } from "@tsparticles/engine";
export declare class SizeUpdater implements IParticleUpdater {

@@ -3,0 +3,0 @@ init(particle: Particle): void;

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

const SizeUpdater_1 = require("./SizeUpdater");
async function loadSizeUpdater(engine) {
await engine.addParticleUpdater("size", () => new SizeUpdater_1.SizeUpdater());
async function loadSizeUpdater(engine, refresh = true) {
await engine.addParticleUpdater("size", () => new SizeUpdater_1.SizeUpdater(), refresh);
}
exports.loadSizeUpdater = loadSizeUpdater;
});

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

else if (typeof define === "function" && define.amd) {
define(["require", "exports", "@tsparticles/engine"], factory);
define(["require", "exports", "@tsparticles/engine", "./Utils"], factory);
}

@@ -15,64 +15,9 @@ })(function (require, exports) {

const engine_1 = require("@tsparticles/engine");
function checkDestroy(particle, value, minValue, maxValue) {
switch (particle.options.size.animation.destroy) {
case "max":
if (value >= maxValue) {
particle.destroy();
}
break;
case "min":
if (value <= minValue) {
particle.destroy();
}
break;
}
}
function updateSize(particle, delta) {
var _a, _b, _c, _d, _e;
const sizeVelocity = ((_a = particle.size.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor, minValue = particle.size.min, maxValue = particle.size.max, decay = (_b = particle.size.decay) !== null && _b !== void 0 ? _b : 1;
if (particle.destroyed ||
!particle.size.enable ||
(((_c = particle.size.maxLoops) !== null && _c !== void 0 ? _c : 0) > 0 && ((_d = particle.size.loops) !== null && _d !== void 0 ? _d : 0) > ((_e = particle.size.maxLoops) !== null && _e !== void 0 ? _e : 0))) {
return;
}
switch (particle.size.status) {
case "increasing":
if (particle.size.value >= maxValue) {
particle.size.status = "decreasing";
if (!particle.size.loops) {
particle.size.loops = 0;
}
particle.size.loops++;
}
else {
particle.size.value += sizeVelocity;
}
break;
case "decreasing":
if (particle.size.value <= minValue) {
particle.size.status = "increasing";
if (!particle.size.loops) {
particle.size.loops = 0;
}
particle.size.loops++;
}
else {
particle.size.value -= sizeVelocity;
}
}
if (particle.size.velocity && decay !== 1) {
particle.size.velocity *= decay;
}
checkDestroy(particle, particle.size.value, minValue, maxValue);
if (!particle.destroyed) {
particle.size.value = (0, engine_1.clamp)(particle.size.value, minValue, maxValue);
}
}
const Utils_1 = require("./Utils");
class SizeUpdater {
init(particle) {
var _a;
const container = particle.container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
if (sizeAnimation.enable) {
particle.size.velocity =
(((_a = particle.retina.sizeAnimationSpeed) !== null && _a !== void 0 ? _a : container.retina.sizeAnimationSpeed) / 100) *
((particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / 100) *
container.retina.reduceFactor;

@@ -85,8 +30,7 @@ if (!sizeAnimation.sync) {

isEnabled(particle) {
var _a, _b, _c, _d;
return (!particle.destroyed &&
!particle.spawning &&
particle.size.enable &&
(((_a = particle.size.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 ||
(((_b = particle.size.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.size.loops) !== null && _c !== void 0 ? _c : 0) < ((_d = particle.size.maxLoops) !== null && _d !== void 0 ? _d : 0))));
((particle.size.maxLoops ?? 0) <= 0 ||
((particle.size.maxLoops ?? 0) > 0 && (particle.size.loops ?? 0) < (particle.size.maxLoops ?? 0))));
}

@@ -100,3 +44,3 @@ reset(particle) {

}
updateSize(particle, delta);
(0, Utils_1.updateSize)(particle, delta);
}

@@ -103,0 +47,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