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

tsparticles-updater-color

Package Overview
Dependencies
Maintainers
2
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsparticles-updater-color - npm Package Compare versions

Comparing version 2.3.3 to 2.4.0

7

browser/ColorUpdater.js

@@ -9,6 +9,6 @@ import { getHslAnimationFromHsl, randomInRange, rangeColorToHsl } from "tsparticles-engine";

const offset = randomInRange(valueAnimation.offset), velocity = ((_a = value.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor + offset * 3.6, decay = (_b = value.decay) !== null && _b !== void 0 ? _b : 1;
if (!decrease || colorValue.status === 0 /* AnimationStatus.increasing */) {
if (!decrease || colorValue.status === 0) {
colorValue.value += velocity;
if (decrease && colorValue.value > max) {
colorValue.status = 1 /* AnimationStatus.decreasing */;
colorValue.status = 1;
colorValue.value -= colorValue.value % max;

@@ -20,3 +20,3 @@ }

if (colorValue.value < 0) {
colorValue.status = 0 /* AnimationStatus.increasing */;
colorValue.status = 0;
colorValue.value += colorValue.value;

@@ -50,3 +50,2 @@ }

init(particle) {
/* color */
const hslColor = rangeColorToHsl(particle.options.color, particle.id, particle.options.reduceDuplicates);

@@ -53,0 +52,0 @@ if (hslColor) {

"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.loadColorUpdater = void 0;
const ColorUpdater_1 = require("./ColorUpdater");
async function loadColorUpdater(engine) {
await engine.addParticleUpdater("color", (container) => new ColorUpdater_1.ColorUpdater(container));
function loadColorUpdater(engine) {
return __awaiter(this, void 0, void 0, function* () {
yield engine.addParticleUpdater("color", (container) => new ColorUpdater_1.ColorUpdater(container));
});
}
exports.loadColorUpdater = loadColorUpdater;
{
"name": "tsparticles-updater-color",
"version": "2.3.3",
"version": "2.4.0",
"description": "tsParticles particles color updater",

@@ -77,4 +77,4 @@ "homepage": "https://particles.js.org",

"dependencies": {
"tsparticles-engine": "^2.3.3"
"tsparticles-engine": "^2.4.0"
}
}

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

* How to use? : Check the GitHub README
* v2.3.3
* v2.4.0
*/

@@ -102,25 +102,15 @@ (function webpackUniversalModuleDefinition(root, factory) {

function updateColorValue(delta, value, valueAnimation, max, decrease) {
var _a, _b;
const colorValue = value;
if (!colorValue || !valueAnimation.enable) {
return;
}
const offset = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.randomInRange)(valueAnimation.offset),
velocity = ((_a = value.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor + offset * 3.6,
decay = (_b = value.decay) !== null && _b !== void 0 ? _b : 1;
if (!decrease || colorValue.status === 0
/* AnimationStatus.increasing */
) {
velocity = ((_a = value.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor + offset * 3.6,
decay = (_b = value.decay) !== null && _b !== void 0 ? _b : 1;
if (!decrease || colorValue.status === 0) {
colorValue.value += velocity;
if (decrease && colorValue.value > max) {
colorValue.status = 1
/* AnimationStatus.decreasing */
;
colorValue.status = 1;
colorValue.value -= colorValue.value % max;

@@ -130,15 +120,10 @@ }

colorValue.value -= velocity;
if (colorValue.value < 0) {
colorValue.status = 0
/* AnimationStatus.increasing */
;
colorValue.status = 0;
colorValue.value += colorValue.value;
}
}
if (colorValue.velocity && decay !== 1) {
colorValue.velocity *= decay;
}
if (colorValue.value > max) {

@@ -148,16 +133,11 @@ colorValue.value %= max;

}
function updateColor(particle, delta) {
var _a, _b, _c;
const animationOptions = particle.options.color.animation;
if (((_a = particle.color) === null || _a === void 0 ? void 0 : _a.h) !== undefined) {
updateColorValue(delta, particle.color.h, animationOptions.h, 360, false);
}
if (((_b = particle.color) === null || _b === void 0 ? void 0 : _b.s) !== undefined) {
updateColorValue(delta, particle.color.s, animationOptions.s, 100, true);
}
if (((_c = particle.color) === null || _c === void 0 ? void 0 : _c.l) !== undefined) {

@@ -167,3 +147,2 @@ updateColorValue(delta, particle.color.l, animationOptions.l, 100, true);

}
class ColorUpdater {

@@ -173,7 +152,4 @@ constructor(container) {

}
init(particle) {
/* color */
const hslColor = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.rangeColorToHsl)(particle.options.color, particle.id, particle.options.reduceDuplicates);
if (hslColor) {

@@ -183,14 +159,10 @@ particle.color = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getHslAnimationFromHsl)(hslColor, particle.options.color.animation, this.container.retina.reduceFactor);

}
isEnabled(particle) {
var _a, _b, _c;
const animationOptions = particle.options.color.animation;
return !particle.destroyed && !particle.spawning && (((_a = particle.color) === null || _a === void 0 ? void 0 : _a.h.value) !== undefined && animationOptions.h.enable || ((_b = particle.color) === null || _b === void 0 ? void 0 : _b.s.value) !== undefined && animationOptions.s.enable || ((_c = particle.color) === null || _c === void 0 ? void 0 : _c.l.value) !== undefined && animationOptions.l.enable);
}
update(particle, delta) {
updateColor(particle, delta);
}
}

@@ -197,0 +169,0 @@ ;// CONCATENATED MODULE: ./dist/browser/index.js

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

* How to use? : Check the GitHub README
* v2.3.3
* v2.4.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