@tsparticles/updater-size 3.0.0-alpha.1 → 3.0.0-beta.1

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.
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  # tsParticles Size Updater
4
4
 
5
- [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/tsparticles-updater-size/badge)](https://www.jsdelivr.com/package/npm/tsparticles-updater-size)
6
- [![npmjs](https://badge.fury.io/js/tsparticles-updater-size.svg)](https://www.npmjs.com/package/tsparticles-updater-size)
7
- [![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)
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/updater-size/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/updater-size)
6
+ [![npmjs](https://badge.fury.io/js/@tsparticles/updater-size.svg)](https://www.npmjs.com/package/@tsparticles/updater-size)
7
+ [![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)
8
8
 
9
9
  [tsParticles](https://github.com/matteobruni/tsparticles) updater plugin for size animations.
10
10
 
@@ -26,7 +26,7 @@ Once the scripts are loaded you can set up `tsParticles` and the updater plugin
26
26
 
27
27
  ```javascript
28
28
  (async () => {
29
- await loadSizeUpdater();
29
+ await loadSizeUpdater(tsParticles);
30
30
 
31
31
  await tsParticles.load({
32
32
  id: "tsparticles",
@@ -42,29 +42,33 @@ Once the scripts are loaded you can set up `tsParticles` and the updater plugin
42
42
  This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
43
43
 
44
44
  ```shell
45
- $ npm install tsparticles-updater-size
45
+ $ npm install @tsparticles/updater-size
46
46
  ```
47
47
 
48
48
  or
49
49
 
50
50
  ```shell
51
- $ yarn add tsparticles-updater-size
51
+ $ yarn add @tsparticles/updater-size
52
52
  ```
53
53
 
54
54
  Then you need to import it in the app, like this:
55
55
 
56
56
  ```javascript
57
- const { tsParticles } = require("tsparticles-engine");
58
- const { loadSizeUpdater } = require("tsparticles-updater-size");
57
+ const { tsParticles } = require("@tsparticles/engine");
58
+ const { loadSizeUpdater } = require("@tsparticles/updater-size");
59
59
 
60
- loadSizeUpdater(tsParticles);
60
+ (async () => {
61
+ await loadSizeUpdater(tsParticles);
62
+ })();
61
63
  ```
62
64
 
63
65
  or
64
66
 
65
67
  ```javascript
66
- import { tsParticles } from "tsparticles-engine";
67
- import { loadSizeUpdater } from "tsparticles-updater-size";
68
+ import { tsParticles } from "@tsparticles/engine";
69
+ import { loadSizeUpdater } from "@tsparticles/updater-size";
68
70
 
69
- loadSizeUpdater(tsParticles);
71
+ (async () => {
72
+ await loadSizeUpdater(tsParticles);
73
+ })();
70
74
  ```
@@ -1,66 +1,11 @@
1
- import { clamp, getRandom } from "@tsparticles/engine";
2
- function checkDestroy(particle, value, minValue, maxValue) {
3
- switch (particle.options.size.animation.destroy) {
4
- case "max":
5
- if (value >= maxValue) {
6
- particle.destroy();
7
- }
8
- break;
9
- case "min":
10
- if (value <= minValue) {
11
- particle.destroy();
12
- }
13
- break;
14
- }
15
- }
16
- function updateSize(particle, delta) {
17
- var _a, _b, _c, _d, _e;
18
- 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;
19
- if (particle.destroyed ||
20
- !particle.size.enable ||
21
- (((_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))) {
22
- return;
23
- }
24
- switch (particle.size.status) {
25
- case "increasing":
26
- if (particle.size.value >= maxValue) {
27
- particle.size.status = "decreasing";
28
- if (!particle.size.loops) {
29
- particle.size.loops = 0;
30
- }
31
- particle.size.loops++;
32
- }
33
- else {
34
- particle.size.value += sizeVelocity;
35
- }
36
- break;
37
- case "decreasing":
38
- if (particle.size.value <= minValue) {
39
- particle.size.status = "increasing";
40
- if (!particle.size.loops) {
41
- particle.size.loops = 0;
42
- }
43
- particle.size.loops++;
44
- }
45
- else {
46
- particle.size.value -= sizeVelocity;
47
- }
48
- }
49
- if (particle.size.velocity && decay !== 1) {
50
- particle.size.velocity *= decay;
51
- }
52
- checkDestroy(particle, particle.size.value, minValue, maxValue);
53
- if (!particle.destroyed) {
54
- particle.size.value = clamp(particle.size.value, minValue, maxValue);
55
- }
56
- }
1
+ import { getRandom } from "@tsparticles/engine";
2
+ import { updateSize } from "./Utils.js";
57
3
  export class SizeUpdater {
58
4
  init(particle) {
59
- var _a;
60
5
  const container = particle.container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
61
6
  if (sizeAnimation.enable) {
62
7
  particle.size.velocity =
63
- (((_a = particle.retina.sizeAnimationSpeed) !== null && _a !== void 0 ? _a : container.retina.sizeAnimationSpeed) / 100) *
8
+ ((particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / 100) *
64
9
  container.retina.reduceFactor;
65
10
  if (!sizeAnimation.sync) {
66
11
  particle.size.velocity *= getRandom();
@@ -68,12 +13,11 @@ export class SizeUpdater {
68
13
  }
69
14
  }
70
15
  isEnabled(particle) {
71
- var _a, _b, _c, _d;
72
16
  return (!particle.destroyed &&
73
17
  !particle.spawning &&
74
18
  particle.size.enable &&
75
- (((_a = particle.size.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 ||
76
- (((_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))));
19
+ ((particle.size.maxLoops ?? 0) <= 0 ||
20
+ ((particle.size.maxLoops ?? 0) > 0 && (particle.size.loops ?? 0) < (particle.size.maxLoops ?? 0))));
77
21
  }
78
22
  reset(particle) {
79
23
  particle.size.loops = 0;
@@ -0,0 +1,66 @@
1
+ import { clamp } from "@tsparticles/engine";
2
+ function checkDestroy(particle, value, minValue, maxValue) {
3
+ switch (particle.options.size.animation.destroy) {
4
+ case "max":
5
+ if (value >= maxValue) {
6
+ particle.destroy();
7
+ }
8
+ break;
9
+ case "min":
10
+ if (value <= minValue) {
11
+ particle.destroy();
12
+ }
13
+ break;
14
+ }
15
+ }
16
+ export function updateSize(particle, delta) {
17
+ const data = particle.size;
18
+ if (particle.destroyed ||
19
+ !data ||
20
+ !data.enable ||
21
+ ((data.maxLoops ?? 0) > 0 && (data.loops ?? 0) > (data.maxLoops ?? 0))) {
22
+ return;
23
+ }
24
+ const sizeVelocity = (data.velocity ?? 0) * delta.factor, minValue = data.min, maxValue = data.max, decay = data.decay ?? 1;
25
+ if (!data.time) {
26
+ data.time = 0;
27
+ }
28
+ if ((data.delayTime ?? 0) > 0 && data.time < (data.delayTime ?? 0)) {
29
+ data.time += delta.value;
30
+ }
31
+ if ((data.delayTime ?? 0) > 0 && data.time < (data.delayTime ?? 0)) {
32
+ return;
33
+ }
34
+ switch (data.status) {
35
+ case "increasing":
36
+ if (data.value >= maxValue) {
37
+ data.status = "decreasing";
38
+ if (!data.loops) {
39
+ data.loops = 0;
40
+ }
41
+ data.loops++;
42
+ }
43
+ else {
44
+ data.value += sizeVelocity;
45
+ }
46
+ break;
47
+ case "decreasing":
48
+ if (data.value <= minValue) {
49
+ data.status = "increasing";
50
+ if (!data.loops) {
51
+ data.loops = 0;
52
+ }
53
+ data.loops++;
54
+ }
55
+ else {
56
+ data.value -= sizeVelocity;
57
+ }
58
+ }
59
+ if (data.velocity && decay !== 1) {
60
+ data.velocity *= decay;
61
+ }
62
+ checkDestroy(particle, data.value, minValue, maxValue);
63
+ if (!particle.destroyed) {
64
+ data.value = clamp(data.value, minValue, maxValue);
65
+ }
66
+ }
package/browser/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { SizeUpdater } from "./SizeUpdater";
2
- export async function loadSizeUpdater(engine) {
3
- await engine.addParticleUpdater("size", () => new SizeUpdater());
1
+ import { SizeUpdater } from "./SizeUpdater.js";
2
+ export async function loadSizeUpdater(engine, refresh = true) {
3
+ await engine.addParticleUpdater("size", () => new SizeUpdater(), refresh);
4
4
  }
@@ -0,0 +1 @@
1
+ { "type": "module" }
@@ -2,68 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SizeUpdater = void 0;
4
4
  const engine_1 = require("@tsparticles/engine");
5
- function checkDestroy(particle, value, minValue, maxValue) {
6
- switch (particle.options.size.animation.destroy) {
7
- case "max":
8
- if (value >= maxValue) {
9
- particle.destroy();
10
- }
11
- break;
12
- case "min":
13
- if (value <= minValue) {
14
- particle.destroy();
15
- }
16
- break;
17
- }
18
- }
19
- function updateSize(particle, delta) {
20
- var _a, _b, _c, _d, _e;
21
- 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;
22
- if (particle.destroyed ||
23
- !particle.size.enable ||
24
- (((_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))) {
25
- return;
26
- }
27
- switch (particle.size.status) {
28
- case "increasing":
29
- if (particle.size.value >= maxValue) {
30
- particle.size.status = "decreasing";
31
- if (!particle.size.loops) {
32
- particle.size.loops = 0;
33
- }
34
- particle.size.loops++;
35
- }
36
- else {
37
- particle.size.value += sizeVelocity;
38
- }
39
- break;
40
- case "decreasing":
41
- if (particle.size.value <= minValue) {
42
- particle.size.status = "increasing";
43
- if (!particle.size.loops) {
44
- particle.size.loops = 0;
45
- }
46
- particle.size.loops++;
47
- }
48
- else {
49
- particle.size.value -= sizeVelocity;
50
- }
51
- }
52
- if (particle.size.velocity && decay !== 1) {
53
- particle.size.velocity *= decay;
54
- }
55
- checkDestroy(particle, particle.size.value, minValue, maxValue);
56
- if (!particle.destroyed) {
57
- particle.size.value = (0, engine_1.clamp)(particle.size.value, minValue, maxValue);
58
- }
59
- }
5
+ const Utils_js_1 = require("./Utils.js");
60
6
  class SizeUpdater {
61
7
  init(particle) {
62
- var _a;
63
8
  const container = particle.container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
64
9
  if (sizeAnimation.enable) {
65
10
  particle.size.velocity =
66
- (((_a = particle.retina.sizeAnimationSpeed) !== null && _a !== void 0 ? _a : container.retina.sizeAnimationSpeed) / 100) *
11
+ ((particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / 100) *
67
12
  container.retina.reduceFactor;
68
13
  if (!sizeAnimation.sync) {
69
14
  particle.size.velocity *= (0, engine_1.getRandom)();
@@ -71,12 +16,11 @@ class SizeUpdater {
71
16
  }
72
17
  }
73
18
  isEnabled(particle) {
74
- var _a, _b, _c, _d;
75
19
  return (!particle.destroyed &&
76
20
  !particle.spawning &&
77
21
  particle.size.enable &&
78
- (((_a = particle.size.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 ||
79
- (((_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))));
22
+ ((particle.size.maxLoops ?? 0) <= 0 ||
23
+ ((particle.size.maxLoops ?? 0) > 0 && (particle.size.loops ?? 0) < (particle.size.maxLoops ?? 0))));
80
24
  }
81
25
  reset(particle) {
82
26
  particle.size.loops = 0;
@@ -85,7 +29,7 @@ class SizeUpdater {
85
29
  if (!this.isEnabled(particle)) {
86
30
  return;
87
31
  }
88
- updateSize(particle, delta);
32
+ (0, Utils_js_1.updateSize)(particle, delta);
89
33
  }
90
34
  }
91
35
  exports.SizeUpdater = SizeUpdater;
package/cjs/Utils.js ADDED
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateSize = void 0;
4
+ const engine_1 = require("@tsparticles/engine");
5
+ function checkDestroy(particle, value, minValue, maxValue) {
6
+ switch (particle.options.size.animation.destroy) {
7
+ case "max":
8
+ if (value >= maxValue) {
9
+ particle.destroy();
10
+ }
11
+ break;
12
+ case "min":
13
+ if (value <= minValue) {
14
+ particle.destroy();
15
+ }
16
+ break;
17
+ }
18
+ }
19
+ function updateSize(particle, delta) {
20
+ const data = particle.size;
21
+ if (particle.destroyed ||
22
+ !data ||
23
+ !data.enable ||
24
+ ((data.maxLoops ?? 0) > 0 && (data.loops ?? 0) > (data.maxLoops ?? 0))) {
25
+ return;
26
+ }
27
+ const sizeVelocity = (data.velocity ?? 0) * delta.factor, minValue = data.min, maxValue = data.max, decay = data.decay ?? 1;
28
+ if (!data.time) {
29
+ data.time = 0;
30
+ }
31
+ if ((data.delayTime ?? 0) > 0 && data.time < (data.delayTime ?? 0)) {
32
+ data.time += delta.value;
33
+ }
34
+ if ((data.delayTime ?? 0) > 0 && data.time < (data.delayTime ?? 0)) {
35
+ return;
36
+ }
37
+ switch (data.status) {
38
+ case "increasing":
39
+ if (data.value >= maxValue) {
40
+ data.status = "decreasing";
41
+ if (!data.loops) {
42
+ data.loops = 0;
43
+ }
44
+ data.loops++;
45
+ }
46
+ else {
47
+ data.value += sizeVelocity;
48
+ }
49
+ break;
50
+ case "decreasing":
51
+ if (data.value <= minValue) {
52
+ data.status = "increasing";
53
+ if (!data.loops) {
54
+ data.loops = 0;
55
+ }
56
+ data.loops++;
57
+ }
58
+ else {
59
+ data.value -= sizeVelocity;
60
+ }
61
+ }
62
+ if (data.velocity && decay !== 1) {
63
+ data.velocity *= decay;
64
+ }
65
+ checkDestroy(particle, data.value, minValue, maxValue);
66
+ if (!particle.destroyed) {
67
+ data.value = (0, engine_1.clamp)(data.value, minValue, maxValue);
68
+ }
69
+ }
70
+ exports.updateSize = updateSize;
package/cjs/index.js CHANGED
@@ -1,19 +1,8 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.loadSizeUpdater = void 0;
13
- const SizeUpdater_1 = require("./SizeUpdater");
14
- function loadSizeUpdater(engine) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- yield engine.addParticleUpdater("size", () => new SizeUpdater_1.SizeUpdater());
17
- });
4
+ const SizeUpdater_js_1 = require("./SizeUpdater.js");
5
+ async function loadSizeUpdater(engine, refresh = true) {
6
+ await engine.addParticleUpdater("size", () => new SizeUpdater_js_1.SizeUpdater(), refresh);
18
7
  }
19
8
  exports.loadSizeUpdater = loadSizeUpdater;
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }
@@ -1,66 +1,11 @@
1
- import { clamp, getRandom } from "@tsparticles/engine";
2
- function checkDestroy(particle, value, minValue, maxValue) {
3
- switch (particle.options.size.animation.destroy) {
4
- case "max":
5
- if (value >= maxValue) {
6
- particle.destroy();
7
- }
8
- break;
9
- case "min":
10
- if (value <= minValue) {
11
- particle.destroy();
12
- }
13
- break;
14
- }
15
- }
16
- function updateSize(particle, delta) {
17
- var _a, _b, _c, _d, _e;
18
- 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;
19
- if (particle.destroyed ||
20
- !particle.size.enable ||
21
- (((_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))) {
22
- return;
23
- }
24
- switch (particle.size.status) {
25
- case "increasing":
26
- if (particle.size.value >= maxValue) {
27
- particle.size.status = "decreasing";
28
- if (!particle.size.loops) {
29
- particle.size.loops = 0;
30
- }
31
- particle.size.loops++;
32
- }
33
- else {
34
- particle.size.value += sizeVelocity;
35
- }
36
- break;
37
- case "decreasing":
38
- if (particle.size.value <= minValue) {
39
- particle.size.status = "increasing";
40
- if (!particle.size.loops) {
41
- particle.size.loops = 0;
42
- }
43
- particle.size.loops++;
44
- }
45
- else {
46
- particle.size.value -= sizeVelocity;
47
- }
48
- }
49
- if (particle.size.velocity && decay !== 1) {
50
- particle.size.velocity *= decay;
51
- }
52
- checkDestroy(particle, particle.size.value, minValue, maxValue);
53
- if (!particle.destroyed) {
54
- particle.size.value = clamp(particle.size.value, minValue, maxValue);
55
- }
56
- }
1
+ import { getRandom } from "@tsparticles/engine";
2
+ import { updateSize } from "./Utils.js";
57
3
  export class SizeUpdater {
58
4
  init(particle) {
59
- var _a;
60
5
  const container = particle.container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
61
6
  if (sizeAnimation.enable) {
62
7
  particle.size.velocity =
63
- (((_a = particle.retina.sizeAnimationSpeed) !== null && _a !== void 0 ? _a : container.retina.sizeAnimationSpeed) / 100) *
8
+ ((particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / 100) *
64
9
  container.retina.reduceFactor;
65
10
  if (!sizeAnimation.sync) {
66
11
  particle.size.velocity *= getRandom();
@@ -68,12 +13,11 @@ export class SizeUpdater {
68
13
  }
69
14
  }
70
15
  isEnabled(particle) {
71
- var _a, _b, _c, _d;
72
16
  return (!particle.destroyed &&
73
17
  !particle.spawning &&
74
18
  particle.size.enable &&
75
- (((_a = particle.size.maxLoops) !== null && _a !== void 0 ? _a : 0) <= 0 ||
76
- (((_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))));
19
+ ((particle.size.maxLoops ?? 0) <= 0 ||
20
+ ((particle.size.maxLoops ?? 0) > 0 && (particle.size.loops ?? 0) < (particle.size.maxLoops ?? 0))));
77
21
  }
78
22
  reset(particle) {
79
23
  particle.size.loops = 0;
package/esm/Utils.js ADDED
@@ -0,0 +1,66 @@
1
+ import { clamp } from "@tsparticles/engine";
2
+ function checkDestroy(particle, value, minValue, maxValue) {
3
+ switch (particle.options.size.animation.destroy) {
4
+ case "max":
5
+ if (value >= maxValue) {
6
+ particle.destroy();
7
+ }
8
+ break;
9
+ case "min":
10
+ if (value <= minValue) {
11
+ particle.destroy();
12
+ }
13
+ break;
14
+ }
15
+ }
16
+ export function updateSize(particle, delta) {
17
+ const data = particle.size;
18
+ if (particle.destroyed ||
19
+ !data ||
20
+ !data.enable ||
21
+ ((data.maxLoops ?? 0) > 0 && (data.loops ?? 0) > (data.maxLoops ?? 0))) {
22
+ return;
23
+ }
24
+ const sizeVelocity = (data.velocity ?? 0) * delta.factor, minValue = data.min, maxValue = data.max, decay = data.decay ?? 1;
25
+ if (!data.time) {
26
+ data.time = 0;
27
+ }
28
+ if ((data.delayTime ?? 0) > 0 && data.time < (data.delayTime ?? 0)) {
29
+ data.time += delta.value;
30
+ }
31
+ if ((data.delayTime ?? 0) > 0 && data.time < (data.delayTime ?? 0)) {
32
+ return;
33
+ }
34
+ switch (data.status) {
35
+ case "increasing":
36
+ if (data.value >= maxValue) {
37
+ data.status = "decreasing";
38
+ if (!data.loops) {
39
+ data.loops = 0;
40
+ }
41
+ data.loops++;
42
+ }
43
+ else {
44
+ data.value += sizeVelocity;
45
+ }
46
+ break;
47
+ case "decreasing":
48
+ if (data.value <= minValue) {
49
+ data.status = "increasing";
50
+ if (!data.loops) {
51
+ data.loops = 0;
52
+ }
53
+ data.loops++;
54
+ }
55
+ else {
56
+ data.value -= sizeVelocity;
57
+ }
58
+ }
59
+ if (data.velocity && decay !== 1) {
60
+ data.velocity *= decay;
61
+ }
62
+ checkDestroy(particle, data.value, minValue, maxValue);
63
+ if (!particle.destroyed) {
64
+ data.value = clamp(data.value, minValue, maxValue);
65
+ }
66
+ }
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { SizeUpdater } from "./SizeUpdater";
2
- export async function loadSizeUpdater(engine) {
3
- await engine.addParticleUpdater("size", () => new SizeUpdater());
1
+ import { SizeUpdater } from "./SizeUpdater.js";
2
+ export async function loadSizeUpdater(engine, refresh = true) {
3
+ await engine.addParticleUpdater("size", () => new SizeUpdater(), refresh);
4
4
  }
@@ -0,0 +1 @@
1
+ { "type": "module" }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/updater-size",
3
- "version": "3.0.0-alpha.1",
3
+ "version": "3.0.0-beta.1",
4
4
  "description": "tsParticles particles size updater",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -68,15 +68,28 @@
68
68
  "bugs": {
69
69
  "url": "https://github.com/matteobruni/tsparticles/issues"
70
70
  },
71
- "main": "cjs/index.js",
71
+ "sideEffects": false,
72
72
  "jsdelivr": "tsparticles.updater.size.min.js",
73
73
  "unpkg": "tsparticles.updater.size.min.js",
74
+ "browser": "browser/index.js",
75
+ "main": "cjs/index.js",
74
76
  "module": "esm/index.js",
75
77
  "types": "types/index.d.ts",
76
- "publishConfig": {
77
- "access": "public"
78
+ "exports": {
79
+ ".": {
80
+ "types": "./types/index.d.ts",
81
+ "browser": "./browser/index.js",
82
+ "import": "./esm/index.js",
83
+ "require": "./cjs/index.js",
84
+ "umd": "./umd/index.js",
85
+ "default": "./cjs/index.js"
86
+ },
87
+ "./package.json": "./package.json"
78
88
  },
79
89
  "dependencies": {
80
- "@tsparticles/engine": "^3.0.0-alpha.1"
90
+ "@tsparticles/engine": "^3.0.0-beta.1"
91
+ },
92
+ "publishConfig": {
93
+ "access": "public"
81
94
  }
82
- }
95
+ }