@tsparticles/updater-opacity 4.0.5 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,16 +1,20 @@
1
1
  import { getRandom, getRangeValue, initParticleNumericAnimationValue, percentDenominator, updateAnimation, } from "@tsparticles/engine";
2
+ import { Opacity } from "./Options/Classes/Opacity.js";
2
3
  export class OpacityUpdater {
3
- container;
4
+ #container;
4
5
  constructor(container) {
5
- this.container = container;
6
+ this.#container = container;
6
7
  }
7
8
  init(particle) {
8
9
  const opacityOptions = particle.options.opacity, pxRatio = 1;
10
+ if (!opacityOptions) {
11
+ return;
12
+ }
9
13
  particle.opacity = initParticleNumericAnimationValue(opacityOptions, pxRatio);
10
14
  const opacityAnimation = opacityOptions.animation;
11
15
  if (opacityAnimation.enable) {
12
16
  particle.opacity.velocity =
13
- (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.container.retina.reduceFactor;
17
+ (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.#container.retina.reduceFactor;
14
18
  if (!opacityAnimation.sync) {
15
19
  particle.opacity.velocity *= getRandom();
16
20
  }
@@ -26,6 +30,12 @@ export class OpacityUpdater {
26
30
  ((particle.opacity.maxLoops ?? none) > none &&
27
31
  (particle.opacity.loops ?? none) < (particle.opacity.maxLoops ?? none))));
28
32
  }
33
+ loadOptions(options, ...sources) {
34
+ options.opacity ??= new Opacity();
35
+ for (const source of sources) {
36
+ options.opacity.load(source?.opacity);
37
+ }
38
+ }
29
39
  reset(particle) {
30
40
  if (!particle.opacity) {
31
41
  return;
@@ -34,7 +44,7 @@ export class OpacityUpdater {
34
44
  particle.opacity.loops = 0;
35
45
  }
36
46
  update(particle, delta) {
37
- if (!this.isEnabled(particle) || !particle.opacity) {
47
+ if (!this.isEnabled(particle) || !particle.opacity || !particle.options.opacity) {
38
48
  return;
39
49
  }
40
50
  updateAnimation(particle, particle.opacity, true, particle.options.opacity.animation.destroy, delta);
@@ -0,0 +1,20 @@
1
+ import { RangedAnimationValueWithRandom, isNull } from "@tsparticles/engine";
2
+ import { OpacityAnimation } from "./OpacityAnimation.js";
3
+ export class Opacity extends RangedAnimationValueWithRandom {
4
+ animation;
5
+ constructor() {
6
+ super();
7
+ this.animation = new OpacityAnimation();
8
+ this.value = 1;
9
+ }
10
+ load(data) {
11
+ if (isNull(data)) {
12
+ return;
13
+ }
14
+ super.load(data);
15
+ const animation = data.animation;
16
+ if (animation !== undefined) {
17
+ this.animation.load(animation);
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,18 @@
1
+ import { DestroyType, RangedAnimationOptions, isNull, } from "@tsparticles/engine";
2
+ export class OpacityAnimation extends RangedAnimationOptions {
3
+ destroy;
4
+ constructor() {
5
+ super();
6
+ this.destroy = DestroyType.none;
7
+ this.speed = 2;
8
+ }
9
+ load(data) {
10
+ super.load(data);
11
+ if (isNull(data)) {
12
+ return;
13
+ }
14
+ if (data.destroy !== undefined) {
15
+ this.destroy = data.destroy;
16
+ }
17
+ }
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/browser/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { OpacityUpdater } from "./OpacityUpdater.js";
2
2
  export async function loadOpacityUpdater(engine) {
3
- engine.checkVersion("4.0.5");
3
+ engine.checkVersion("4.1.0");
4
4
  await engine.pluginManager.register(e => {
5
5
  e.pluginManager.addParticleUpdater("opacity", container => {
6
6
  return Promise.resolve(new OpacityUpdater(container));
@@ -1,5 +1,5 @@
1
1
  export async function loadOpacityUpdater(engine) {
2
- engine.checkVersion("4.0.5");
2
+ engine.checkVersion("4.1.0");
3
3
  await engine.pluginManager.register(e => {
4
4
  e.pluginManager.addParticleUpdater("opacity", async (container) => {
5
5
  const { OpacityUpdater } = await import("./OpacityUpdater.js");
@@ -1,16 +1,20 @@
1
1
  import { getRandom, getRangeValue, initParticleNumericAnimationValue, percentDenominator, updateAnimation, } from "@tsparticles/engine";
2
+ import { Opacity } from "./Options/Classes/Opacity.js";
2
3
  export class OpacityUpdater {
3
- container;
4
+ #container;
4
5
  constructor(container) {
5
- this.container = container;
6
+ this.#container = container;
6
7
  }
7
8
  init(particle) {
8
9
  const opacityOptions = particle.options.opacity, pxRatio = 1;
10
+ if (!opacityOptions) {
11
+ return;
12
+ }
9
13
  particle.opacity = initParticleNumericAnimationValue(opacityOptions, pxRatio);
10
14
  const opacityAnimation = opacityOptions.animation;
11
15
  if (opacityAnimation.enable) {
12
16
  particle.opacity.velocity =
13
- (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.container.retina.reduceFactor;
17
+ (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.#container.retina.reduceFactor;
14
18
  if (!opacityAnimation.sync) {
15
19
  particle.opacity.velocity *= getRandom();
16
20
  }
@@ -26,6 +30,12 @@ export class OpacityUpdater {
26
30
  ((particle.opacity.maxLoops ?? none) > none &&
27
31
  (particle.opacity.loops ?? none) < (particle.opacity.maxLoops ?? none))));
28
32
  }
33
+ loadOptions(options, ...sources) {
34
+ options.opacity ??= new Opacity();
35
+ for (const source of sources) {
36
+ options.opacity.load(source?.opacity);
37
+ }
38
+ }
29
39
  reset(particle) {
30
40
  if (!particle.opacity) {
31
41
  return;
@@ -34,7 +44,7 @@ export class OpacityUpdater {
34
44
  particle.opacity.loops = 0;
35
45
  }
36
46
  update(particle, delta) {
37
- if (!this.isEnabled(particle) || !particle.opacity) {
47
+ if (!this.isEnabled(particle) || !particle.opacity || !particle.options.opacity) {
38
48
  return;
39
49
  }
40
50
  updateAnimation(particle, particle.opacity, true, particle.options.opacity.animation.destroy, delta);
@@ -0,0 +1,20 @@
1
+ import { RangedAnimationValueWithRandom, isNull } from "@tsparticles/engine";
2
+ import { OpacityAnimation } from "./OpacityAnimation.js";
3
+ export class Opacity extends RangedAnimationValueWithRandom {
4
+ animation;
5
+ constructor() {
6
+ super();
7
+ this.animation = new OpacityAnimation();
8
+ this.value = 1;
9
+ }
10
+ load(data) {
11
+ if (isNull(data)) {
12
+ return;
13
+ }
14
+ super.load(data);
15
+ const animation = data.animation;
16
+ if (animation !== undefined) {
17
+ this.animation.load(animation);
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,18 @@
1
+ import { DestroyType, RangedAnimationOptions, isNull, } from "@tsparticles/engine";
2
+ export class OpacityAnimation extends RangedAnimationOptions {
3
+ destroy;
4
+ constructor() {
5
+ super();
6
+ this.destroy = DestroyType.none;
7
+ this.speed = 2;
8
+ }
9
+ load(data) {
10
+ super.load(data);
11
+ if (isNull(data)) {
12
+ return;
13
+ }
14
+ if (data.destroy !== undefined) {
15
+ this.destroy = data.destroy;
16
+ }
17
+ }
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/cjs/Types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { OpacityUpdater } from "./OpacityUpdater.js";
2
2
  export async function loadOpacityUpdater(engine) {
3
- engine.checkVersion("4.0.5");
3
+ engine.checkVersion("4.1.0");
4
4
  await engine.pluginManager.register(e => {
5
5
  e.pluginManager.addParticleUpdater("opacity", container => {
6
6
  return Promise.resolve(new OpacityUpdater(container));
package/cjs/index.lazy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export async function loadOpacityUpdater(engine) {
2
- engine.checkVersion("4.0.5");
2
+ engine.checkVersion("4.1.0");
3
3
  await engine.pluginManager.register(e => {
4
4
  e.pluginManager.addParticleUpdater("opacity", async (container) => {
5
5
  const { OpacityUpdater } = await import("./OpacityUpdater.js");
@@ -1,16 +1,20 @@
1
1
  import { getRandom, getRangeValue, initParticleNumericAnimationValue, percentDenominator, updateAnimation, } from "@tsparticles/engine";
2
+ import { Opacity } from "./Options/Classes/Opacity.js";
2
3
  export class OpacityUpdater {
3
- container;
4
+ #container;
4
5
  constructor(container) {
5
- this.container = container;
6
+ this.#container = container;
6
7
  }
7
8
  init(particle) {
8
9
  const opacityOptions = particle.options.opacity, pxRatio = 1;
10
+ if (!opacityOptions) {
11
+ return;
12
+ }
9
13
  particle.opacity = initParticleNumericAnimationValue(opacityOptions, pxRatio);
10
14
  const opacityAnimation = opacityOptions.animation;
11
15
  if (opacityAnimation.enable) {
12
16
  particle.opacity.velocity =
13
- (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.container.retina.reduceFactor;
17
+ (getRangeValue(opacityAnimation.speed) / percentDenominator) * this.#container.retina.reduceFactor;
14
18
  if (!opacityAnimation.sync) {
15
19
  particle.opacity.velocity *= getRandom();
16
20
  }
@@ -26,6 +30,12 @@ export class OpacityUpdater {
26
30
  ((particle.opacity.maxLoops ?? none) > none &&
27
31
  (particle.opacity.loops ?? none) < (particle.opacity.maxLoops ?? none))));
28
32
  }
33
+ loadOptions(options, ...sources) {
34
+ options.opacity ??= new Opacity();
35
+ for (const source of sources) {
36
+ options.opacity.load(source?.opacity);
37
+ }
38
+ }
29
39
  reset(particle) {
30
40
  if (!particle.opacity) {
31
41
  return;
@@ -34,7 +44,7 @@ export class OpacityUpdater {
34
44
  particle.opacity.loops = 0;
35
45
  }
36
46
  update(particle, delta) {
37
- if (!this.isEnabled(particle) || !particle.opacity) {
47
+ if (!this.isEnabled(particle) || !particle.opacity || !particle.options.opacity) {
38
48
  return;
39
49
  }
40
50
  updateAnimation(particle, particle.opacity, true, particle.options.opacity.animation.destroy, delta);
@@ -0,0 +1,20 @@
1
+ import { RangedAnimationValueWithRandom, isNull } from "@tsparticles/engine";
2
+ import { OpacityAnimation } from "./OpacityAnimation.js";
3
+ export class Opacity extends RangedAnimationValueWithRandom {
4
+ animation;
5
+ constructor() {
6
+ super();
7
+ this.animation = new OpacityAnimation();
8
+ this.value = 1;
9
+ }
10
+ load(data) {
11
+ if (isNull(data)) {
12
+ return;
13
+ }
14
+ super.load(data);
15
+ const animation = data.animation;
16
+ if (animation !== undefined) {
17
+ this.animation.load(animation);
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,18 @@
1
+ import { DestroyType, RangedAnimationOptions, isNull, } from "@tsparticles/engine";
2
+ export class OpacityAnimation extends RangedAnimationOptions {
3
+ destroy;
4
+ constructor() {
5
+ super();
6
+ this.destroy = DestroyType.none;
7
+ this.speed = 2;
8
+ }
9
+ load(data) {
10
+ super.load(data);
11
+ if (isNull(data)) {
12
+ return;
13
+ }
14
+ if (data.destroy !== undefined) {
15
+ this.destroy = data.destroy;
16
+ }
17
+ }
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/esm/Types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { OpacityUpdater } from "./OpacityUpdater.js";
2
2
  export async function loadOpacityUpdater(engine) {
3
- engine.checkVersion("4.0.5");
3
+ engine.checkVersion("4.1.0");
4
4
  await engine.pluginManager.register(e => {
5
5
  e.pluginManager.addParticleUpdater("opacity", container => {
6
6
  return Promise.resolve(new OpacityUpdater(container));
package/esm/index.lazy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export async function loadOpacityUpdater(engine) {
2
- engine.checkVersion("4.0.5");
2
+ engine.checkVersion("4.1.0");
3
3
  await engine.pluginManager.register(e => {
4
4
  e.pluginManager.addParticleUpdater("opacity", async (container) => {
5
5
  const { OpacityUpdater } = await import("./OpacityUpdater.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/updater-opacity",
3
- "version": "4.0.5",
3
+ "version": "4.1.0",
4
4
  "description": "tsParticles particles opacity updater",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -93,7 +93,7 @@
93
93
  "./package.json": "./package.json"
94
94
  },
95
95
  "peerDependencies": {
96
- "@tsparticles/engine": "4.0.5"
96
+ "@tsparticles/engine": "4.1.0"
97
97
  },
98
98
  "publishConfig": {
99
99
  "access": "public"
package/report.html CHANGED
@@ -4930,7 +4930,7 @@ var drawChart = (function (exports) {
4930
4930
  </script>
4931
4931
  <script>
4932
4932
  /*<!--*/
4933
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"tsparticles.updater.opacity.js","children":[{"name":"dist/browser","children":[{"uid":"0462c09e-1","name":"OpacityUpdater.js"},{"uid":"0462c09e-3","name":"index.js"},{"uid":"0462c09e-5","name":"browser.js"}]}]}],"isRoot":true},"nodeParts":{"0462c09e-1":{"renderedLength":1690,"gzipLength":0,"brotliLength":0,"metaUid":"0462c09e-0"},"0462c09e-3":{"renderedLength":314,"gzipLength":0,"brotliLength":0,"metaUid":"0462c09e-2"},"0462c09e-5":{"renderedLength":179,"gzipLength":0,"brotliLength":0,"metaUid":"0462c09e-4"}},"nodeMetas":{"0462c09e-0":{"id":"/dist/browser/OpacityUpdater.js","moduleParts":{"tsparticles.updater.opacity.js":"0462c09e-1"},"imported":[{"uid":"0462c09e-6"}],"importedBy":[{"uid":"0462c09e-2"}]},"0462c09e-2":{"id":"/dist/browser/index.js","moduleParts":{"tsparticles.updater.opacity.js":"0462c09e-3"},"imported":[{"uid":"0462c09e-0"}],"importedBy":[{"uid":"0462c09e-4"}]},"0462c09e-4":{"id":"/dist/browser/browser.js","moduleParts":{"tsparticles.updater.opacity.js":"0462c09e-5"},"imported":[{"uid":"0462c09e-2"}],"importedBy":[],"isEntry":true},"0462c09e-6":{"id":"@tsparticles/engine","moduleParts":{},"imported":[],"importedBy":[{"uid":"0462c09e-0"}],"isExternal":true}},"env":{"rollup":"4.60.4"},"options":{"gzip":false,"brotli":false,"sourcemap":false}};
4933
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"tsparticles.updater.opacity.js","children":[{"name":"dist/browser","children":[{"name":"Options/Classes","children":[{"uid":"b4877abc-1","name":"OpacityAnimation.js"},{"uid":"b4877abc-3","name":"Opacity.js"}]},{"uid":"b4877abc-5","name":"OpacityUpdater.js"},{"uid":"b4877abc-7","name":"index.js"},{"uid":"b4877abc-9","name":"browser.js"}]}]}],"isRoot":true},"nodeParts":{"b4877abc-1":{"renderedLength":467,"gzipLength":0,"brotliLength":0,"metaUid":"b4877abc-0"},"b4877abc-3":{"renderedLength":515,"gzipLength":0,"brotliLength":0,"metaUid":"b4877abc-2"},"b4877abc-5":{"renderedLength":2008,"gzipLength":0,"brotliLength":0,"metaUid":"b4877abc-4"},"b4877abc-7":{"renderedLength":314,"gzipLength":0,"brotliLength":0,"metaUid":"b4877abc-6"},"b4877abc-9":{"renderedLength":179,"gzipLength":0,"brotliLength":0,"metaUid":"b4877abc-8"}},"nodeMetas":{"b4877abc-0":{"id":"/dist/browser/Options/Classes/OpacityAnimation.js","moduleParts":{"tsparticles.updater.opacity.js":"b4877abc-1"},"imported":[{"uid":"b4877abc-10"}],"importedBy":[{"uid":"b4877abc-2"}]},"b4877abc-2":{"id":"/dist/browser/Options/Classes/Opacity.js","moduleParts":{"tsparticles.updater.opacity.js":"b4877abc-3"},"imported":[{"uid":"b4877abc-10"},{"uid":"b4877abc-0"}],"importedBy":[{"uid":"b4877abc-4"}]},"b4877abc-4":{"id":"/dist/browser/OpacityUpdater.js","moduleParts":{"tsparticles.updater.opacity.js":"b4877abc-5"},"imported":[{"uid":"b4877abc-10"},{"uid":"b4877abc-2"}],"importedBy":[{"uid":"b4877abc-6"}]},"b4877abc-6":{"id":"/dist/browser/index.js","moduleParts":{"tsparticles.updater.opacity.js":"b4877abc-7"},"imported":[{"uid":"b4877abc-4"}],"importedBy":[{"uid":"b4877abc-8"}]},"b4877abc-8":{"id":"/dist/browser/browser.js","moduleParts":{"tsparticles.updater.opacity.js":"b4877abc-9"},"imported":[{"uid":"b4877abc-6"}],"importedBy":[],"isEntry":true},"b4877abc-10":{"id":"@tsparticles/engine","moduleParts":{},"imported":[],"importedBy":[{"uid":"b4877abc-4"},{"uid":"b4877abc-2"},{"uid":"b4877abc-0"}],"isExternal":true}},"env":{"rollup":"4.60.4"},"options":{"gzip":false,"brotli":false,"sourcemap":false}};
4934
4934
 
4935
4935
  const run = () => {
4936
4936
  const width = window.innerWidth;
@@ -1,23 +1,63 @@
1
1
  (function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
2
- /* Updater v4.0.5 */
2
+ /* Updater v4.1.0 */
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tsparticles/engine')) :
5
5
  typeof define === 'function' && define.amd ? define(['exports', '@tsparticles/engine'], factory) :
6
6
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.__tsParticlesInternals = global.__tsParticlesInternals || {}, global.__tsParticlesInternals.updaters = global.__tsParticlesInternals.updaters || {}, global.__tsParticlesInternals.updaters.opacity = global.__tsParticlesInternals.updaters.opacity || {}), global.__tsParticlesInternals.engine));
7
7
  })(this, (function (exports, engine) { 'use strict';
8
8
 
9
+ class OpacityAnimation extends engine.RangedAnimationOptions {
10
+ destroy;
11
+ constructor() {
12
+ super();
13
+ this.destroy = engine.DestroyType.none;
14
+ this.speed = 2;
15
+ }
16
+ load(data) {
17
+ super.load(data);
18
+ if (engine.isNull(data)) {
19
+ return;
20
+ }
21
+ if (data.destroy !== undefined) {
22
+ this.destroy = data.destroy;
23
+ }
24
+ }
25
+ }
26
+
27
+ class Opacity extends engine.RangedAnimationValueWithRandom {
28
+ animation;
29
+ constructor() {
30
+ super();
31
+ this.animation = new OpacityAnimation();
32
+ this.value = 1;
33
+ }
34
+ load(data) {
35
+ if (engine.isNull(data)) {
36
+ return;
37
+ }
38
+ super.load(data);
39
+ const animation = data.animation;
40
+ if (animation !== undefined) {
41
+ this.animation.load(animation);
42
+ }
43
+ }
44
+ }
45
+
9
46
  class OpacityUpdater {
10
- container;
47
+ #container;
11
48
  constructor(container) {
12
- this.container = container;
49
+ this.#container = container;
13
50
  }
14
51
  init(particle) {
15
52
  const opacityOptions = particle.options.opacity, pxRatio = 1;
53
+ if (!opacityOptions) {
54
+ return;
55
+ }
16
56
  particle.opacity = engine.initParticleNumericAnimationValue(opacityOptions, pxRatio);
17
57
  const opacityAnimation = opacityOptions.animation;
18
58
  if (opacityAnimation.enable) {
19
59
  particle.opacity.velocity =
20
- (engine.getRangeValue(opacityAnimation.speed) / engine.percentDenominator) * this.container.retina.reduceFactor;
60
+ (engine.getRangeValue(opacityAnimation.speed) / engine.percentDenominator) * this.#container.retina.reduceFactor;
21
61
  if (!opacityAnimation.sync) {
22
62
  particle.opacity.velocity *= engine.getRandom();
23
63
  }
@@ -33,6 +73,12 @@
33
73
  ((particle.opacity.maxLoops ?? none) > none &&
34
74
  (particle.opacity.loops ?? none) < (particle.opacity.maxLoops ?? none))));
35
75
  }
76
+ loadOptions(options, ...sources) {
77
+ options.opacity ??= new Opacity();
78
+ for (const source of sources) {
79
+ options.opacity.load(source?.opacity);
80
+ }
81
+ }
36
82
  reset(particle) {
37
83
  if (!particle.opacity) {
38
84
  return;
@@ -41,7 +87,7 @@
41
87
  particle.opacity.loops = 0;
42
88
  }
43
89
  update(particle, delta) {
44
- if (!this.isEnabled(particle) || !particle.opacity) {
90
+ if (!this.isEnabled(particle) || !particle.opacity || !particle.options.opacity) {
45
91
  return;
46
92
  }
47
93
  engine.updateAnimation(particle, particle.opacity, true, particle.options.opacity.animation.destroy, delta);
@@ -49,7 +95,7 @@
49
95
  }
50
96
 
51
97
  async function loadOpacityUpdater(engine) {
52
- engine.checkVersion("4.0.5");
98
+ engine.checkVersion("4.1.0");
53
99
  await engine.pluginManager.register(e => {
54
100
  e.pluginManager.addParticleUpdater("opacity", container => {
55
101
  return Promise.resolve(new OpacityUpdater(container));
@@ -1 +1 @@
1
- !function(t){t.__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.engine=t.__tsParticlesInternals.engine||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.palettes=t.__tsParticlesInternals.palettes||{},t.__tsParticlesInternals.paths=t.__tsParticlesInternals.paths||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins.emittersShapes=t.__tsParticlesInternals.plugins.emittersShapes||{},t.__tsParticlesInternals.presets=t.__tsParticlesInternals.presets||{},t.__tsParticlesInternals.shapes=t.__tsParticlesInternals.shapes||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.utils=t.__tsParticlesInternals.utils||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas.utils=t.__tsParticlesInternals.canvas.utils||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path.utils=t.__tsParticlesInternals.path.utils||{};var s="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,s){return s in t||(t[s]={}),t[s]}})}:function(t){return t};t.__tsParticlesInternals.bundles=s(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=s(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=s(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=s(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=s(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=s(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=s(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=s(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=s(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=s(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=s(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=s(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=s(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/engine"],s):s(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.updaters.opacity=t.__tsParticlesInternals.updaters.opacity||{}),t.__tsParticlesInternals.engine)}(this,function(t,s){"use strict";class e{container;constructor(t){this.container=t}init(t){const e=t.options.opacity;t.opacity=s.initParticleNumericAnimationValue(e,1);const a=e.animation;a.enable&&(t.opacity.velocity=s.getRangeValue(a.speed)/s.percentDenominator*this.container.retina.reduceFactor,a.sync||(t.opacity.velocity*=s.getRandom()))}isEnabled(t){return!t.destroyed&&!t.spawning&&!!t.opacity&&t.opacity.enable&&((t.opacity.maxLoops??0)<=0||(t.opacity.maxLoops??0)>0&&(t.opacity.loops??0)<(t.opacity.maxLoops??0))}reset(t){t.opacity&&(t.opacity.time=0,t.opacity.loops=0)}update(t,e){this.isEnabled(t)&&t.opacity&&s.updateAnimation(t,t.opacity,!0,t.options.opacity.animation.destroy,e)}}async function a(t){t.checkVersion("4.0.5"),await t.pluginManager.register(t=>{t.pluginManager.addParticleUpdater("opacity",t=>Promise.resolve(new e(t)))})}const n=globalThis;n.__tsParticlesInternals=n.__tsParticlesInternals??{},n.loadOpacityUpdater=a,t.loadOpacityUpdater=a}),Object.assign(globalThis.window||globalThis,{loadOpacityUpdater:(globalThis.__tsParticlesInternals.updaters.opacity||{}).loadOpacityUpdater}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
1
+ !function(t){t.__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.engine=t.__tsParticlesInternals.engine||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.palettes=t.__tsParticlesInternals.palettes||{},t.__tsParticlesInternals.paths=t.__tsParticlesInternals.paths||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins.emittersShapes=t.__tsParticlesInternals.plugins.emittersShapes||{},t.__tsParticlesInternals.presets=t.__tsParticlesInternals.presets||{},t.__tsParticlesInternals.shapes=t.__tsParticlesInternals.shapes||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.utils=t.__tsParticlesInternals.utils||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas.utils=t.__tsParticlesInternals.canvas.utils||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path.utils=t.__tsParticlesInternals.path.utils||{};var s="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,s){return s in t||(t[s]={}),t[s]}})}:function(t){return t};t.__tsParticlesInternals.bundles=s(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=s(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=s(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=s(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=s(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=s(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=s(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=s(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=s(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=s(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=s(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=s(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=s(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/engine"],s):s(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.updaters.opacity=t.__tsParticlesInternals.updaters.opacity||{}),t.__tsParticlesInternals.engine)}(this,function(t,s){"use strict";class e extends s.RangedAnimationOptions{destroy;constructor(){super(),this.destroy=s.DestroyType.none,this.speed=2}load(t){super.load(t),s.isNull(t)||void 0!==t.destroy&&(this.destroy=t.destroy)}}class a extends s.RangedAnimationValueWithRandom{animation;constructor(){super(),this.animation=new e,this.value=1}load(t){if(s.isNull(t))return;super.load(t);const e=t.animation;void 0!==e&&this.animation.load(e)}}class n{#t;constructor(t){this.#t=t}init(t){const e=t.options.opacity;if(!e)return;t.opacity=s.initParticleNumericAnimationValue(e,1);const a=e.animation;a.enable&&(t.opacity.velocity=s.getRangeValue(a.speed)/s.percentDenominator*this.#t.retina.reduceFactor,a.sync||(t.opacity.velocity*=s.getRandom()))}isEnabled(t){return!t.destroyed&&!t.spawning&&!!t.opacity&&t.opacity.enable&&((t.opacity.maxLoops??0)<=0||(t.opacity.maxLoops??0)>0&&(t.opacity.loops??0)<(t.opacity.maxLoops??0))}loadOptions(t,...s){t.opacity??=new a;for(const e of s)t.opacity.load(e?.opacity)}reset(t){t.opacity&&(t.opacity.time=0,t.opacity.loops=0)}update(t,e){this.isEnabled(t)&&t.opacity&&t.options.opacity&&s.updateAnimation(t,t.opacity,!0,t.options.opacity.animation.destroy,e)}}async function r(t){t.checkVersion("4.1.0"),await t.pluginManager.register(t=>{t.pluginManager.addParticleUpdater("opacity",t=>Promise.resolve(new n(t)))})}const i=globalThis;i.__tsParticlesInternals=i.__tsParticlesInternals??{},i.loadOpacityUpdater=r,t.loadOpacityUpdater=r}),Object.assign(globalThis.window||globalThis,{loadOpacityUpdater:(globalThis.__tsParticlesInternals.updaters.opacity||{}).loadOpacityUpdater}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
@@ -1,9 +1,11 @@
1
- import { type Container, type IDelta, type IParticleUpdater, type Particle } from "@tsparticles/engine";
1
+ import { type Container, type IDelta, type IParticleUpdater, type RecursivePartial } from "@tsparticles/engine";
2
+ import { type IOpacityParticlesOptions, type OpacityParticle, type OpacityParticlesOptions } from "./Types.js";
2
3
  export declare class OpacityUpdater implements IParticleUpdater {
3
- private readonly container;
4
+ #private;
4
5
  constructor(container: Container);
5
- init(particle: Particle): void;
6
- isEnabled(particle: Particle): boolean;
7
- reset(particle: Particle): void;
8
- update(particle: Particle, delta: IDelta): void;
6
+ init(particle: OpacityParticle): void;
7
+ isEnabled(particle: OpacityParticle): boolean;
8
+ loadOptions(options: OpacityParticlesOptions, ...sources: (RecursivePartial<IOpacityParticlesOptions> | undefined)[]): void;
9
+ reset(particle: OpacityParticle): void;
10
+ update(particle: OpacityParticle, delta: IDelta): void;
9
11
  }
@@ -0,0 +1,8 @@
1
+ import { type IOptionLoader, RangedAnimationValueWithRandom, type RecursivePartial } from "@tsparticles/engine";
2
+ import type { IOpacity } from "../Interfaces/IOpacity.js";
3
+ import { OpacityAnimation } from "./OpacityAnimation.js";
4
+ export declare class Opacity extends RangedAnimationValueWithRandom implements IOpacity, IOptionLoader<IOpacity> {
5
+ readonly animation: OpacityAnimation;
6
+ constructor();
7
+ load(data?: RecursivePartial<IOpacity>): void;
8
+ }
@@ -0,0 +1,7 @@
1
+ import { DestroyType, type IOptionLoader, RangedAnimationOptions, type RecursivePartial } from "@tsparticles/engine";
2
+ import type { IOpacityAnimation } from "../Interfaces/IOpacityAnimation.js";
3
+ export declare class OpacityAnimation extends RangedAnimationOptions implements IOpacityAnimation, IOptionLoader<IOpacityAnimation> {
4
+ destroy: DestroyType | keyof typeof DestroyType;
5
+ constructor();
6
+ load(data?: RecursivePartial<IOpacityAnimation>): void;
7
+ }
@@ -0,0 +1,5 @@
1
+ import type { IOpacityAnimation } from "./IOpacityAnimation.js";
2
+ import type { IValueWithRandom } from "@tsparticles/engine";
3
+ export interface IOpacity extends IValueWithRandom {
4
+ animation: IOpacityAnimation;
5
+ }
@@ -0,0 +1,4 @@
1
+ import type { DestroyType, IRangedAnimation } from "@tsparticles/engine";
2
+ export interface IOpacityAnimation extends IRangedAnimation {
3
+ destroy: DestroyType | keyof typeof DestroyType;
4
+ }
@@ -0,0 +1,12 @@
1
+ import { type IParticlesOptions, type Particle, type ParticlesOptions } from "@tsparticles/engine";
2
+ import type { IOpacity } from "./Options/Interfaces/IOpacity.js";
3
+ import type { Opacity } from "./Options/Classes/Opacity.js";
4
+ export type OpacityParticlesOptions = ParticlesOptions & {
5
+ opacity?: Opacity;
6
+ };
7
+ export type IOpacityParticlesOptions = IParticlesOptions & {
8
+ opacity?: IOpacity;
9
+ };
10
+ export type OpacityParticle = Particle & {
11
+ options: OpacityParticlesOptions;
12
+ };