tsparticles-updater-opacity
Advanced tools
Comparing version 2.9.3 to 2.10.0
@@ -1,61 +0,3 @@ | ||
import { clamp, getRandom, getRangeMax, getRangeMin, getRangeValue, randomInRange, } from "tsparticles-engine"; | ||
function checkDestroy(particle, value, minValue, maxValue) { | ||
switch (particle.options.opacity.animation.destroy) { | ||
case "max": | ||
if (value >= maxValue) { | ||
particle.destroy(); | ||
} | ||
break; | ||
case "min": | ||
if (value <= minValue) { | ||
particle.destroy(); | ||
} | ||
break; | ||
} | ||
} | ||
function updateOpacity(particle, delta) { | ||
var _a, _b, _c, _d, _e, _f; | ||
if (!particle.opacity) { | ||
return; | ||
} | ||
const minValue = particle.opacity.min, maxValue = particle.opacity.max, decay = (_a = particle.opacity.decay) !== null && _a !== void 0 ? _a : 1; | ||
if (particle.destroyed || | ||
!particle.opacity.enable || | ||
(((_b = particle.opacity.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.opacity.loops) !== null && _c !== void 0 ? _c : 0) > ((_d = particle.opacity.maxLoops) !== null && _d !== void 0 ? _d : 0))) { | ||
return; | ||
} | ||
switch (particle.opacity.status) { | ||
case "increasing": | ||
if (particle.opacity.value >= maxValue) { | ||
particle.opacity.status = "decreasing"; | ||
if (!particle.opacity.loops) { | ||
particle.opacity.loops = 0; | ||
} | ||
particle.opacity.loops++; | ||
} | ||
else { | ||
particle.opacity.value += ((_e = particle.opacity.velocity) !== null && _e !== void 0 ? _e : 0) * delta.factor; | ||
} | ||
break; | ||
case "decreasing": | ||
if (particle.opacity.value <= minValue) { | ||
particle.opacity.status = "increasing"; | ||
if (!particle.opacity.loops) { | ||
particle.opacity.loops = 0; | ||
} | ||
particle.opacity.loops++; | ||
} | ||
else { | ||
particle.opacity.value -= ((_f = particle.opacity.velocity) !== null && _f !== void 0 ? _f : 0) * delta.factor; | ||
} | ||
break; | ||
} | ||
if (particle.opacity.velocity && particle.opacity.decay !== 1) { | ||
particle.opacity.velocity *= decay; | ||
} | ||
checkDestroy(particle, particle.opacity.value, minValue, maxValue); | ||
if (!particle.destroyed) { | ||
particle.opacity.value = clamp(particle.opacity.value, minValue, maxValue); | ||
} | ||
} | ||
import { getRandom, getRangeValue, initParticleNumericAnimationValue, } from "tsparticles-engine"; | ||
import { updateOpacity } from "./Utils"; | ||
export class OpacityUpdater { | ||
@@ -67,33 +9,5 @@ constructor(container) { | ||
const opacityOptions = particle.options.opacity; | ||
particle.opacity = { | ||
enable: opacityOptions.animation.enable, | ||
max: getRangeMax(opacityOptions.value), | ||
min: getRangeMin(opacityOptions.value), | ||
value: getRangeValue(opacityOptions.value), | ||
loops: 0, | ||
maxLoops: getRangeValue(opacityOptions.animation.count), | ||
}; | ||
particle.opacity = initParticleNumericAnimationValue(opacityOptions, 1); | ||
const opacityAnimation = opacityOptions.animation; | ||
if (opacityAnimation.enable) { | ||
particle.opacity.decay = 1 - getRangeValue(opacityAnimation.decay); | ||
particle.opacity.status = "increasing"; | ||
const opacityRange = opacityOptions.value; | ||
particle.opacity.min = getRangeMin(opacityRange); | ||
particle.opacity.max = getRangeMax(opacityRange); | ||
switch (opacityAnimation.startValue) { | ||
case "min": | ||
particle.opacity.value = particle.opacity.min; | ||
particle.opacity.status = "increasing"; | ||
break; | ||
case "random": | ||
particle.opacity.value = randomInRange(particle.opacity); | ||
particle.opacity.status = | ||
getRandom() >= 0.5 ? "increasing" : "decreasing"; | ||
break; | ||
case "max": | ||
default: | ||
particle.opacity.value = particle.opacity.max; | ||
particle.opacity.status = "decreasing"; | ||
break; | ||
} | ||
particle.opacity.velocity = | ||
@@ -105,6 +19,4 @@ (getRangeValue(opacityAnimation.speed) / 100) * this.container.retina.reduceFactor; | ||
} | ||
particle.opacity.initialValue = particle.opacity.value; | ||
} | ||
isEnabled(particle) { | ||
var _a, _b, _c, _d; | ||
return (!particle.destroyed && | ||
@@ -114,8 +26,9 @@ !particle.spawning && | ||
particle.opacity.enable && | ||
(((_a = particle.opacity.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 || | ||
(((_b = particle.opacity.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && | ||
((_c = particle.opacity.loops) !== null && _c !== void 0 ? _c : 0) < ((_d = particle.opacity.maxLoops) !== null && _d !== void 0 ? _d : 0)))); | ||
((particle.opacity.maxLoops ?? 0) <= 0 || | ||
((particle.opacity.maxLoops ?? 0) > 0 && | ||
(particle.opacity.loops ?? 0) < (particle.opacity.maxLoops ?? 0)))); | ||
} | ||
reset(particle) { | ||
if (particle.opacity) { | ||
particle.opacity.time = 0; | ||
particle.opacity.loops = 0; | ||
@@ -122,0 +35,0 @@ } |
"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.loadOpacityUpdater = void 0; | ||
const OpacityUpdater_1 = require("./OpacityUpdater"); | ||
function loadOpacityUpdater(engine) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield engine.addParticleUpdater("opacity", (container) => new OpacityUpdater_1.OpacityUpdater(container)); | ||
}); | ||
async function loadOpacityUpdater(engine) { | ||
await engine.addParticleUpdater("opacity", (container) => new OpacityUpdater_1.OpacityUpdater(container)); | ||
} | ||
exports.loadOpacityUpdater = loadOpacityUpdater; |
@@ -5,61 +5,3 @@ "use strict"; | ||
const tsparticles_engine_1 = require("tsparticles-engine"); | ||
function checkDestroy(particle, value, minValue, maxValue) { | ||
switch (particle.options.opacity.animation.destroy) { | ||
case "max": | ||
if (value >= maxValue) { | ||
particle.destroy(); | ||
} | ||
break; | ||
case "min": | ||
if (value <= minValue) { | ||
particle.destroy(); | ||
} | ||
break; | ||
} | ||
} | ||
function updateOpacity(particle, delta) { | ||
var _a, _b, _c, _d, _e, _f; | ||
if (!particle.opacity) { | ||
return; | ||
} | ||
const minValue = particle.opacity.min, maxValue = particle.opacity.max, decay = (_a = particle.opacity.decay) !== null && _a !== void 0 ? _a : 1; | ||
if (particle.destroyed || | ||
!particle.opacity.enable || | ||
(((_b = particle.opacity.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.opacity.loops) !== null && _c !== void 0 ? _c : 0) > ((_d = particle.opacity.maxLoops) !== null && _d !== void 0 ? _d : 0))) { | ||
return; | ||
} | ||
switch (particle.opacity.status) { | ||
case "increasing": | ||
if (particle.opacity.value >= maxValue) { | ||
particle.opacity.status = "decreasing"; | ||
if (!particle.opacity.loops) { | ||
particle.opacity.loops = 0; | ||
} | ||
particle.opacity.loops++; | ||
} | ||
else { | ||
particle.opacity.value += ((_e = particle.opacity.velocity) !== null && _e !== void 0 ? _e : 0) * delta.factor; | ||
} | ||
break; | ||
case "decreasing": | ||
if (particle.opacity.value <= minValue) { | ||
particle.opacity.status = "increasing"; | ||
if (!particle.opacity.loops) { | ||
particle.opacity.loops = 0; | ||
} | ||
particle.opacity.loops++; | ||
} | ||
else { | ||
particle.opacity.value -= ((_f = particle.opacity.velocity) !== null && _f !== void 0 ? _f : 0) * delta.factor; | ||
} | ||
break; | ||
} | ||
if (particle.opacity.velocity && particle.opacity.decay !== 1) { | ||
particle.opacity.velocity *= decay; | ||
} | ||
checkDestroy(particle, particle.opacity.value, minValue, maxValue); | ||
if (!particle.destroyed) { | ||
particle.opacity.value = (0, tsparticles_engine_1.clamp)(particle.opacity.value, minValue, maxValue); | ||
} | ||
} | ||
const Utils_1 = require("./Utils"); | ||
class OpacityUpdater { | ||
@@ -71,33 +13,5 @@ constructor(container) { | ||
const opacityOptions = particle.options.opacity; | ||
particle.opacity = { | ||
enable: opacityOptions.animation.enable, | ||
max: (0, tsparticles_engine_1.getRangeMax)(opacityOptions.value), | ||
min: (0, tsparticles_engine_1.getRangeMin)(opacityOptions.value), | ||
value: (0, tsparticles_engine_1.getRangeValue)(opacityOptions.value), | ||
loops: 0, | ||
maxLoops: (0, tsparticles_engine_1.getRangeValue)(opacityOptions.animation.count), | ||
}; | ||
particle.opacity = (0, tsparticles_engine_1.initParticleNumericAnimationValue)(opacityOptions, 1); | ||
const opacityAnimation = opacityOptions.animation; | ||
if (opacityAnimation.enable) { | ||
particle.opacity.decay = 1 - (0, tsparticles_engine_1.getRangeValue)(opacityAnimation.decay); | ||
particle.opacity.status = "increasing"; | ||
const opacityRange = opacityOptions.value; | ||
particle.opacity.min = (0, tsparticles_engine_1.getRangeMin)(opacityRange); | ||
particle.opacity.max = (0, tsparticles_engine_1.getRangeMax)(opacityRange); | ||
switch (opacityAnimation.startValue) { | ||
case "min": | ||
particle.opacity.value = particle.opacity.min; | ||
particle.opacity.status = "increasing"; | ||
break; | ||
case "random": | ||
particle.opacity.value = (0, tsparticles_engine_1.randomInRange)(particle.opacity); | ||
particle.opacity.status = | ||
(0, tsparticles_engine_1.getRandom)() >= 0.5 ? "increasing" : "decreasing"; | ||
break; | ||
case "max": | ||
default: | ||
particle.opacity.value = particle.opacity.max; | ||
particle.opacity.status = "decreasing"; | ||
break; | ||
} | ||
particle.opacity.velocity = | ||
@@ -109,6 +23,4 @@ ((0, tsparticles_engine_1.getRangeValue)(opacityAnimation.speed) / 100) * this.container.retina.reduceFactor; | ||
} | ||
particle.opacity.initialValue = particle.opacity.value; | ||
} | ||
isEnabled(particle) { | ||
var _a, _b, _c, _d; | ||
return (!particle.destroyed && | ||
@@ -118,8 +30,9 @@ !particle.spawning && | ||
particle.opacity.enable && | ||
(((_a = particle.opacity.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 || | ||
(((_b = particle.opacity.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && | ||
((_c = particle.opacity.loops) !== null && _c !== void 0 ? _c : 0) < ((_d = particle.opacity.maxLoops) !== null && _d !== void 0 ? _d : 0)))); | ||
((particle.opacity.maxLoops ?? 0) <= 0 || | ||
((particle.opacity.maxLoops ?? 0) > 0 && | ||
(particle.opacity.loops ?? 0) < (particle.opacity.maxLoops ?? 0)))); | ||
} | ||
reset(particle) { | ||
if (particle.opacity) { | ||
particle.opacity.time = 0; | ||
particle.opacity.loops = 0; | ||
@@ -132,5 +45,5 @@ } | ||
} | ||
updateOpacity(particle, delta); | ||
(0, Utils_1.updateOpacity)(particle, delta); | ||
} | ||
} | ||
exports.OpacityUpdater = OpacityUpdater; |
@@ -1,61 +0,3 @@ | ||
import { clamp, getRandom, getRangeMax, getRangeMin, getRangeValue, randomInRange, } from "tsparticles-engine"; | ||
function checkDestroy(particle, value, minValue, maxValue) { | ||
switch (particle.options.opacity.animation.destroy) { | ||
case "max": | ||
if (value >= maxValue) { | ||
particle.destroy(); | ||
} | ||
break; | ||
case "min": | ||
if (value <= minValue) { | ||
particle.destroy(); | ||
} | ||
break; | ||
} | ||
} | ||
function updateOpacity(particle, delta) { | ||
var _a, _b, _c, _d, _e, _f; | ||
if (!particle.opacity) { | ||
return; | ||
} | ||
const minValue = particle.opacity.min, maxValue = particle.opacity.max, decay = (_a = particle.opacity.decay) !== null && _a !== void 0 ? _a : 1; | ||
if (particle.destroyed || | ||
!particle.opacity.enable || | ||
(((_b = particle.opacity.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.opacity.loops) !== null && _c !== void 0 ? _c : 0) > ((_d = particle.opacity.maxLoops) !== null && _d !== void 0 ? _d : 0))) { | ||
return; | ||
} | ||
switch (particle.opacity.status) { | ||
case "increasing": | ||
if (particle.opacity.value >= maxValue) { | ||
particle.opacity.status = "decreasing"; | ||
if (!particle.opacity.loops) { | ||
particle.opacity.loops = 0; | ||
} | ||
particle.opacity.loops++; | ||
} | ||
else { | ||
particle.opacity.value += ((_e = particle.opacity.velocity) !== null && _e !== void 0 ? _e : 0) * delta.factor; | ||
} | ||
break; | ||
case "decreasing": | ||
if (particle.opacity.value <= minValue) { | ||
particle.opacity.status = "increasing"; | ||
if (!particle.opacity.loops) { | ||
particle.opacity.loops = 0; | ||
} | ||
particle.opacity.loops++; | ||
} | ||
else { | ||
particle.opacity.value -= ((_f = particle.opacity.velocity) !== null && _f !== void 0 ? _f : 0) * delta.factor; | ||
} | ||
break; | ||
} | ||
if (particle.opacity.velocity && particle.opacity.decay !== 1) { | ||
particle.opacity.velocity *= decay; | ||
} | ||
checkDestroy(particle, particle.opacity.value, minValue, maxValue); | ||
if (!particle.destroyed) { | ||
particle.opacity.value = clamp(particle.opacity.value, minValue, maxValue); | ||
} | ||
} | ||
import { getRandom, getRangeValue, initParticleNumericAnimationValue, } from "tsparticles-engine"; | ||
import { updateOpacity } from "./Utils"; | ||
export class OpacityUpdater { | ||
@@ -67,33 +9,5 @@ constructor(container) { | ||
const opacityOptions = particle.options.opacity; | ||
particle.opacity = { | ||
enable: opacityOptions.animation.enable, | ||
max: getRangeMax(opacityOptions.value), | ||
min: getRangeMin(opacityOptions.value), | ||
value: getRangeValue(opacityOptions.value), | ||
loops: 0, | ||
maxLoops: getRangeValue(opacityOptions.animation.count), | ||
}; | ||
particle.opacity = initParticleNumericAnimationValue(opacityOptions, 1); | ||
const opacityAnimation = opacityOptions.animation; | ||
if (opacityAnimation.enable) { | ||
particle.opacity.decay = 1 - getRangeValue(opacityAnimation.decay); | ||
particle.opacity.status = "increasing"; | ||
const opacityRange = opacityOptions.value; | ||
particle.opacity.min = getRangeMin(opacityRange); | ||
particle.opacity.max = getRangeMax(opacityRange); | ||
switch (opacityAnimation.startValue) { | ||
case "min": | ||
particle.opacity.value = particle.opacity.min; | ||
particle.opacity.status = "increasing"; | ||
break; | ||
case "random": | ||
particle.opacity.value = randomInRange(particle.opacity); | ||
particle.opacity.status = | ||
getRandom() >= 0.5 ? "increasing" : "decreasing"; | ||
break; | ||
case "max": | ||
default: | ||
particle.opacity.value = particle.opacity.max; | ||
particle.opacity.status = "decreasing"; | ||
break; | ||
} | ||
particle.opacity.velocity = | ||
@@ -105,6 +19,4 @@ (getRangeValue(opacityAnimation.speed) / 100) * this.container.retina.reduceFactor; | ||
} | ||
particle.opacity.initialValue = particle.opacity.value; | ||
} | ||
isEnabled(particle) { | ||
var _a, _b, _c, _d; | ||
return (!particle.destroyed && | ||
@@ -114,8 +26,9 @@ !particle.spawning && | ||
particle.opacity.enable && | ||
(((_a = particle.opacity.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 || | ||
(((_b = particle.opacity.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && | ||
((_c = particle.opacity.loops) !== null && _c !== void 0 ? _c : 0) < ((_d = particle.opacity.maxLoops) !== null && _d !== void 0 ? _d : 0)))); | ||
((particle.opacity.maxLoops ?? 0) <= 0 || | ||
((particle.opacity.maxLoops ?? 0) > 0 && | ||
(particle.opacity.loops ?? 0) < (particle.opacity.maxLoops ?? 0)))); | ||
} | ||
reset(particle) { | ||
if (particle.opacity) { | ||
particle.opacity.time = 0; | ||
particle.opacity.loops = 0; | ||
@@ -122,0 +35,0 @@ } |
{ | ||
"name": "tsparticles-updater-opacity", | ||
"version": "2.9.3", | ||
"version": "2.10.0", | ||
"description": "tsParticles particles opacity updater", | ||
@@ -77,4 +77,4 @@ "homepage": "https://particles.js.org", | ||
"dependencies": { | ||
"tsparticles-engine": "^2.9.3" | ||
"tsparticles-engine": "^2.10.0" | ||
} | ||
} |
@@ -7,3 +7,3 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v2.9.3 | ||
* v2.10.0 | ||
*/ | ||
@@ -95,3 +95,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
__webpack_require__.d(__webpack_exports__, { | ||
"loadOpacityUpdater": () => (/* binding */ loadOpacityUpdater) | ||
loadOpacityUpdater: () => (/* binding */ loadOpacityUpdater) | ||
}); | ||
@@ -101,3 +101,3 @@ | ||
var external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_ = __webpack_require__(961); | ||
;// CONCATENATED MODULE: ./dist/browser/OpacityUpdater.js | ||
;// CONCATENATED MODULE: ./dist/browser/Utils.js | ||
@@ -119,44 +119,53 @@ function checkDestroy(particle, value, minValue, maxValue) { | ||
function updateOpacity(particle, delta) { | ||
var _a, _b, _c, _d, _e, _f; | ||
if (!particle.opacity) { | ||
const data = particle.opacity; | ||
if (particle.destroyed || !data?.enable || (data.maxLoops ?? 0) > 0 && (data.loops ?? 0) > (data.maxLoops ?? 0)) { | ||
return; | ||
} | ||
const minValue = particle.opacity.min, | ||
maxValue = particle.opacity.max, | ||
decay = (_a = particle.opacity.decay) !== null && _a !== void 0 ? _a : 1; | ||
if (particle.destroyed || !particle.opacity.enable || ((_b = particle.opacity.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.opacity.loops) !== null && _c !== void 0 ? _c : 0) > ((_d = particle.opacity.maxLoops) !== null && _d !== void 0 ? _d : 0)) { | ||
const 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 (particle.opacity.status) { | ||
switch (data.status) { | ||
case "increasing": | ||
if (particle.opacity.value >= maxValue) { | ||
particle.opacity.status = "decreasing"; | ||
if (!particle.opacity.loops) { | ||
particle.opacity.loops = 0; | ||
if (data.value >= maxValue) { | ||
data.status = "decreasing"; | ||
if (!data.loops) { | ||
data.loops = 0; | ||
} | ||
particle.opacity.loops++; | ||
data.loops++; | ||
} else { | ||
particle.opacity.value += ((_e = particle.opacity.velocity) !== null && _e !== void 0 ? _e : 0) * delta.factor; | ||
data.value += (data.velocity ?? 0) * delta.factor; | ||
} | ||
break; | ||
case "decreasing": | ||
if (particle.opacity.value <= minValue) { | ||
particle.opacity.status = "increasing"; | ||
if (!particle.opacity.loops) { | ||
particle.opacity.loops = 0; | ||
if (data.value <= minValue) { | ||
data.status = "increasing"; | ||
if (!data.loops) { | ||
data.loops = 0; | ||
} | ||
particle.opacity.loops++; | ||
data.loops++; | ||
} else { | ||
particle.opacity.value -= ((_f = particle.opacity.velocity) !== null && _f !== void 0 ? _f : 0) * delta.factor; | ||
data.value -= (data.velocity ?? 0) * delta.factor; | ||
} | ||
break; | ||
} | ||
if (particle.opacity.velocity && particle.opacity.decay !== 1) { | ||
particle.opacity.velocity *= decay; | ||
if (data.velocity && data.decay !== 1) { | ||
data.velocity *= decay; | ||
} | ||
checkDestroy(particle, particle.opacity.value, minValue, maxValue); | ||
checkDestroy(particle, data.value, minValue, maxValue); | ||
if (!particle.destroyed) { | ||
particle.opacity.value = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.clamp)(particle.opacity.value, minValue, maxValue); | ||
data.value = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.clamp)(data.value, minValue, maxValue); | ||
} | ||
} | ||
;// CONCATENATED MODULE: ./dist/browser/OpacityUpdater.js | ||
class OpacityUpdater { | ||
@@ -168,32 +177,5 @@ constructor(container) { | ||
const opacityOptions = particle.options.opacity; | ||
particle.opacity = { | ||
enable: opacityOptions.animation.enable, | ||
max: (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeMax)(opacityOptions.value), | ||
min: (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeMin)(opacityOptions.value), | ||
value: (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeValue)(opacityOptions.value), | ||
loops: 0, | ||
maxLoops: (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeValue)(opacityOptions.animation.count) | ||
}; | ||
particle.opacity = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.initParticleNumericAnimationValue)(opacityOptions, 1); | ||
const opacityAnimation = opacityOptions.animation; | ||
if (opacityAnimation.enable) { | ||
particle.opacity.decay = 1 - (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeValue)(opacityAnimation.decay); | ||
particle.opacity.status = "increasing"; | ||
const opacityRange = opacityOptions.value; | ||
particle.opacity.min = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeMin)(opacityRange); | ||
particle.opacity.max = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeMax)(opacityRange); | ||
switch (opacityAnimation.startValue) { | ||
case "min": | ||
particle.opacity.value = particle.opacity.min; | ||
particle.opacity.status = "increasing"; | ||
break; | ||
case "random": | ||
particle.opacity.value = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.randomInRange)(particle.opacity); | ||
particle.opacity.status = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRandom)() >= 0.5 ? "increasing" : "decreasing"; | ||
break; | ||
case "max": | ||
default: | ||
particle.opacity.value = particle.opacity.max; | ||
particle.opacity.status = "decreasing"; | ||
break; | ||
} | ||
particle.opacity.velocity = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getRangeValue)(opacityAnimation.speed) / 100 * this.container.retina.reduceFactor; | ||
@@ -204,10 +186,9 @@ if (!opacityAnimation.sync) { | ||
} | ||
particle.opacity.initialValue = particle.opacity.value; | ||
} | ||
isEnabled(particle) { | ||
var _a, _b, _c, _d; | ||
return !particle.destroyed && !particle.spawning && !!particle.opacity && particle.opacity.enable && (((_a = particle.opacity.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 || ((_b = particle.opacity.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.opacity.loops) !== null && _c !== void 0 ? _c : 0) < ((_d = particle.opacity.maxLoops) !== null && _d !== void 0 ? _d : 0)); | ||
return !particle.destroyed && !particle.spawning && !!particle.opacity && particle.opacity.enable && ((particle.opacity.maxLoops ?? 0) <= 0 || (particle.opacity.maxLoops ?? 0) > 0 && (particle.opacity.loops ?? 0) < (particle.opacity.maxLoops ?? 0)); | ||
} | ||
reset(particle) { | ||
if (particle.opacity) { | ||
particle.opacity.time = 0; | ||
particle.opacity.loops = 0; | ||
@@ -214,0 +195,0 @@ } |
/*! For license information please see tsparticles.updater.opacity.min.js.LICENSE.txt */ | ||
!function(a,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 t="object"==typeof exports?e(require("tsparticles-engine")):e(a.window);for(var o in t)("object"==typeof exports?exports:a)[o]=t[o]}}(this,(a=>(()=>{"use strict";var e={961:e=>{e.exports=a}},t={};function o(a){var i=t[a];if(void 0!==i)return i.exports;var c=t[a]={exports:{}};return e[a](c,c.exports,o),c.exports}o.d=(a,e)=>{for(var t in e)o.o(e,t)&&!o.o(a,t)&&Object.defineProperty(a,t,{enumerable:!0,get:e[t]})},o.o=(a,e)=>Object.prototype.hasOwnProperty.call(a,e),o.r=a=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})};var i={};return(()=>{o.r(i),o.d(i,{loadOpacityUpdater:()=>t});var a=o(961);class e{constructor(a){this.container=a}init(e){const t=e.options.opacity;e.opacity={enable:t.animation.enable,max:(0,a.getRangeMax)(t.value),min:(0,a.getRangeMin)(t.value),value:(0,a.getRangeValue)(t.value),loops:0,maxLoops:(0,a.getRangeValue)(t.animation.count)};const o=t.animation;if(o.enable){e.opacity.decay=1-(0,a.getRangeValue)(o.decay),e.opacity.status="increasing";const i=t.value;switch(e.opacity.min=(0,a.getRangeMin)(i),e.opacity.max=(0,a.getRangeMax)(i),o.startValue){case"min":e.opacity.value=e.opacity.min,e.opacity.status="increasing";break;case"random":e.opacity.value=(0,a.randomInRange)(e.opacity),e.opacity.status=(0,a.getRandom)()>=.5?"increasing":"decreasing";break;default:e.opacity.value=e.opacity.max,e.opacity.status="decreasing"}e.opacity.velocity=(0,a.getRangeValue)(o.speed)/100*this.container.retina.reduceFactor,o.sync||(e.opacity.velocity*=(0,a.getRandom)())}e.opacity.initialValue=e.opacity.value}isEnabled(a){var e,t,o,i;return!a.destroyed&&!a.spawning&&!!a.opacity&&a.opacity.enable&&((null!==(e=a.opacity.maxLoops)&&void 0!==e?e:0)<=0||(null!==(t=a.opacity.maxLoops)&&void 0!==t?t:0)>0&&(null!==(o=a.opacity.loops)&&void 0!==o?o:0)<(null!==(i=a.opacity.maxLoops)&&void 0!==i?i:0))}reset(a){a.opacity&&(a.opacity.loops=0)}update(e,t){this.isEnabled(e)&&function(e,t){var o,i,c,n,p,s;if(!e.opacity)return;const y=e.opacity.min,r=e.opacity.max,l=null!==(o=e.opacity.decay)&&void 0!==o?o:1;if(!(e.destroyed||!e.opacity.enable||(null!==(i=e.opacity.maxLoops)&&void 0!==i?i:0)>0&&(null!==(c=e.opacity.loops)&&void 0!==c?c:0)>(null!==(n=e.opacity.maxLoops)&&void 0!==n?n:0))){switch(e.opacity.status){case"increasing":e.opacity.value>=r?(e.opacity.status="decreasing",e.opacity.loops||(e.opacity.loops=0),e.opacity.loops++):e.opacity.value+=(null!==(p=e.opacity.velocity)&&void 0!==p?p:0)*t.factor;break;case"decreasing":e.opacity.value<=y?(e.opacity.status="increasing",e.opacity.loops||(e.opacity.loops=0),e.opacity.loops++):e.opacity.value-=(null!==(s=e.opacity.velocity)&&void 0!==s?s:0)*t.factor}e.opacity.velocity&&1!==e.opacity.decay&&(e.opacity.velocity*=l),function(a,e,t,o){switch(a.options.opacity.animation.destroy){case"max":e>=o&&a.destroy();break;case"min":e<=t&&a.destroy()}}(e,e.opacity.value,y,r),e.destroyed||(e.opacity.value=(0,a.clamp)(e.opacity.value,y,r))}}(e,t)}}async function t(a){await a.addParticleUpdater("opacity",(a=>new e(a)))}})(),i})())); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("tsparticles-engine"));else if("function"==typeof define&&define.amd)define(["tsparticles-engine"],t);else{var o="object"==typeof exports?t(require("tsparticles-engine")):t(e.window);for(var a in o)("object"==typeof exports?exports:e)[a]=o[a]}}(this,(e=>(()=>{"use strict";var t={961:t=>{t.exports=e}},o={};function a(e){var i=o[e];if(void 0!==i)return i.exports;var r=o[e]={exports:{}};return t[e](r,r.exports,a),r.exports}a.d=(e,t)=>{for(var o in t)a.o(t,o)&&!a.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{a.r(i),a.d(i,{loadOpacityUpdater:()=>o});var e=a(961);class t{constructor(e){this.container=e}init(t){const o=t.options.opacity;t.opacity=(0,e.initParticleNumericAnimationValue)(o,1);const a=o.animation;a.enable&&(t.opacity.velocity=(0,e.getRangeValue)(a.speed)/100*this.container.retina.reduceFactor,a.sync||(t.opacity.velocity*=(0,e.getRandom)()))}isEnabled(e){return!e.destroyed&&!e.spawning&&!!e.opacity&&e.opacity.enable&&((e.opacity.maxLoops??0)<=0||(e.opacity.maxLoops??0)>0&&(e.opacity.loops??0)<(e.opacity.maxLoops??0))}reset(e){e.opacity&&(e.opacity.time=0,e.opacity.loops=0)}update(t,o){this.isEnabled(t)&&function(t,o){const a=t.opacity;if(t.destroyed||!a?.enable||(a.maxLoops??0)>0&&(a.loops??0)>(a.maxLoops??0))return;const i=a.min,r=a.max,n=a.decay??1;if(a.time||(a.time=0),(a.delayTime??0)>0&&a.time<(a.delayTime??0)&&(a.time+=o.value),!((a.delayTime??0)>0&&a.time<(a.delayTime??0))){switch(a.status){case"increasing":a.value>=r?(a.status="decreasing",a.loops||(a.loops=0),a.loops++):a.value+=(a.velocity??0)*o.factor;break;case"decreasing":a.value<=i?(a.status="increasing",a.loops||(a.loops=0),a.loops++):a.value-=(a.velocity??0)*o.factor}a.velocity&&1!==a.decay&&(a.velocity*=n),function(e,t,o,a){switch(e.options.opacity.animation.destroy){case"max":t>=a&&e.destroy();break;case"min":t<=o&&e.destroy()}}(t,a.value,i,r),t.destroyed||(a.value=(0,e.clamp)(a.value,i,r))}}(t,o)}}async function o(e){await e.addParticleUpdater("opacity",(e=>new t(e)))}})(),i})())); |
@@ -1,1 +0,1 @@ | ||
/*! tsParticles Opacity Updater v2.9.3 by Matteo Bruni */ | ||
/*! tsParticles Opacity Updater v2.10.0 by Matteo Bruni */ |
@@ -1,2 +0,2 @@ | ||
import type { Container, IDelta, IParticleUpdater, Particle } from "tsparticles-engine"; | ||
import { type Container, type IDelta, type IParticleUpdater, type Particle } from "tsparticles-engine"; | ||
export declare class OpacityUpdater implements IParticleUpdater { | ||
@@ -3,0 +3,0 @@ private readonly container; |
@@ -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,61 +15,3 @@ })(function (require, exports) { | ||
const tsparticles_engine_1 = require("tsparticles-engine"); | ||
function checkDestroy(particle, value, minValue, maxValue) { | ||
switch (particle.options.opacity.animation.destroy) { | ||
case "max": | ||
if (value >= maxValue) { | ||
particle.destroy(); | ||
} | ||
break; | ||
case "min": | ||
if (value <= minValue) { | ||
particle.destroy(); | ||
} | ||
break; | ||
} | ||
} | ||
function updateOpacity(particle, delta) { | ||
var _a, _b, _c, _d, _e, _f; | ||
if (!particle.opacity) { | ||
return; | ||
} | ||
const minValue = particle.opacity.min, maxValue = particle.opacity.max, decay = (_a = particle.opacity.decay) !== null && _a !== void 0 ? _a : 1; | ||
if (particle.destroyed || | ||
!particle.opacity.enable || | ||
(((_b = particle.opacity.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && ((_c = particle.opacity.loops) !== null && _c !== void 0 ? _c : 0) > ((_d = particle.opacity.maxLoops) !== null && _d !== void 0 ? _d : 0))) { | ||
return; | ||
} | ||
switch (particle.opacity.status) { | ||
case "increasing": | ||
if (particle.opacity.value >= maxValue) { | ||
particle.opacity.status = "decreasing"; | ||
if (!particle.opacity.loops) { | ||
particle.opacity.loops = 0; | ||
} | ||
particle.opacity.loops++; | ||
} | ||
else { | ||
particle.opacity.value += ((_e = particle.opacity.velocity) !== null && _e !== void 0 ? _e : 0) * delta.factor; | ||
} | ||
break; | ||
case "decreasing": | ||
if (particle.opacity.value <= minValue) { | ||
particle.opacity.status = "increasing"; | ||
if (!particle.opacity.loops) { | ||
particle.opacity.loops = 0; | ||
} | ||
particle.opacity.loops++; | ||
} | ||
else { | ||
particle.opacity.value -= ((_f = particle.opacity.velocity) !== null && _f !== void 0 ? _f : 0) * delta.factor; | ||
} | ||
break; | ||
} | ||
if (particle.opacity.velocity && particle.opacity.decay !== 1) { | ||
particle.opacity.velocity *= decay; | ||
} | ||
checkDestroy(particle, particle.opacity.value, minValue, maxValue); | ||
if (!particle.destroyed) { | ||
particle.opacity.value = (0, tsparticles_engine_1.clamp)(particle.opacity.value, minValue, maxValue); | ||
} | ||
} | ||
const Utils_1 = require("./Utils"); | ||
class OpacityUpdater { | ||
@@ -81,33 +23,5 @@ constructor(container) { | ||
const opacityOptions = particle.options.opacity; | ||
particle.opacity = { | ||
enable: opacityOptions.animation.enable, | ||
max: (0, tsparticles_engine_1.getRangeMax)(opacityOptions.value), | ||
min: (0, tsparticles_engine_1.getRangeMin)(opacityOptions.value), | ||
value: (0, tsparticles_engine_1.getRangeValue)(opacityOptions.value), | ||
loops: 0, | ||
maxLoops: (0, tsparticles_engine_1.getRangeValue)(opacityOptions.animation.count), | ||
}; | ||
particle.opacity = (0, tsparticles_engine_1.initParticleNumericAnimationValue)(opacityOptions, 1); | ||
const opacityAnimation = opacityOptions.animation; | ||
if (opacityAnimation.enable) { | ||
particle.opacity.decay = 1 - (0, tsparticles_engine_1.getRangeValue)(opacityAnimation.decay); | ||
particle.opacity.status = "increasing"; | ||
const opacityRange = opacityOptions.value; | ||
particle.opacity.min = (0, tsparticles_engine_1.getRangeMin)(opacityRange); | ||
particle.opacity.max = (0, tsparticles_engine_1.getRangeMax)(opacityRange); | ||
switch (opacityAnimation.startValue) { | ||
case "min": | ||
particle.opacity.value = particle.opacity.min; | ||
particle.opacity.status = "increasing"; | ||
break; | ||
case "random": | ||
particle.opacity.value = (0, tsparticles_engine_1.randomInRange)(particle.opacity); | ||
particle.opacity.status = | ||
(0, tsparticles_engine_1.getRandom)() >= 0.5 ? "increasing" : "decreasing"; | ||
break; | ||
case "max": | ||
default: | ||
particle.opacity.value = particle.opacity.max; | ||
particle.opacity.status = "decreasing"; | ||
break; | ||
} | ||
particle.opacity.velocity = | ||
@@ -119,6 +33,4 @@ ((0, tsparticles_engine_1.getRangeValue)(opacityAnimation.speed) / 100) * this.container.retina.reduceFactor; | ||
} | ||
particle.opacity.initialValue = particle.opacity.value; | ||
} | ||
isEnabled(particle) { | ||
var _a, _b, _c, _d; | ||
return (!particle.destroyed && | ||
@@ -128,8 +40,9 @@ !particle.spawning && | ||
particle.opacity.enable && | ||
(((_a = particle.opacity.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 || | ||
(((_b = particle.opacity.maxLoops) !== null && _b !== void 0 ? _b : 0) > 0 && | ||
((_c = particle.opacity.loops) !== null && _c !== void 0 ? _c : 0) < ((_d = particle.opacity.maxLoops) !== null && _d !== void 0 ? _d : 0)))); | ||
((particle.opacity.maxLoops ?? 0) <= 0 || | ||
((particle.opacity.maxLoops ?? 0) > 0 && | ||
(particle.opacity.loops ?? 0) < (particle.opacity.maxLoops ?? 0)))); | ||
} | ||
reset(particle) { | ||
if (particle.opacity) { | ||
particle.opacity.time = 0; | ||
particle.opacity.loops = 0; | ||
@@ -142,3 +55,3 @@ } | ||
} | ||
updateOpacity(particle, delta); | ||
(0, Utils_1.updateOpacity)(particle, delta); | ||
} | ||
@@ -145,0 +58,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
22
311539
696
1
Updatedtsparticles-engine@^2.10.0