@tsparticles/updater-size 3.0.3 → 3.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,11 +1,11 @@
1
- import { getRandom } from "@tsparticles/engine";
2
- import { updateSize } from "./Utils.js";
1
+ import { getRandom, percentDenominator, updateAnimation, } from "@tsparticles/engine";
2
+ const minLoops = 0;
3
3
  export class SizeUpdater {
4
4
  init(particle) {
5
5
  const container = particle.container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
6
6
  if (sizeAnimation.enable) {
7
7
  particle.size.velocity =
8
- ((particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / 100) *
8
+ ((particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / percentDenominator) *
9
9
  container.retina.reduceFactor;
10
10
  if (!sizeAnimation.sync) {
11
11
  particle.size.velocity *= getRandom();
@@ -16,16 +16,17 @@ export class SizeUpdater {
16
16
  return (!particle.destroyed &&
17
17
  !particle.spawning &&
18
18
  particle.size.enable &&
19
- ((particle.size.maxLoops ?? 0) <= 0 ||
20
- ((particle.size.maxLoops ?? 0) > 0 && (particle.size.loops ?? 0) < (particle.size.maxLoops ?? 0))));
19
+ ((particle.size.maxLoops ?? minLoops) <= minLoops ||
20
+ ((particle.size.maxLoops ?? minLoops) > minLoops &&
21
+ (particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
21
22
  }
22
23
  reset(particle) {
23
- particle.size.loops = 0;
24
+ particle.size.loops = minLoops;
24
25
  }
25
26
  update(particle, delta) {
26
27
  if (!this.isEnabled(particle)) {
27
28
  return;
28
29
  }
29
- updateSize(particle, delta);
30
+ updateAnimation(particle, particle.size, true, particle.options.size.animation.destroy, delta);
30
31
  }
31
32
  }
@@ -2,13 +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
- const Utils_js_1 = require("./Utils.js");
5
+ const minLoops = 0;
6
6
  class SizeUpdater {
7
7
  init(particle) {
8
8
  const container = particle.container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
9
9
  if (sizeAnimation.enable) {
10
10
  particle.size.velocity =
11
- ((particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / 100) *
11
+ ((particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / engine_1.percentDenominator) *
12
12
  container.retina.reduceFactor;
13
13
  if (!sizeAnimation.sync) {
14
14
  particle.size.velocity *= (0, engine_1.getRandom)();
@@ -19,17 +19,18 @@ class SizeUpdater {
19
19
  return (!particle.destroyed &&
20
20
  !particle.spawning &&
21
21
  particle.size.enable &&
22
- ((particle.size.maxLoops ?? 0) <= 0 ||
23
- ((particle.size.maxLoops ?? 0) > 0 && (particle.size.loops ?? 0) < (particle.size.maxLoops ?? 0))));
22
+ ((particle.size.maxLoops ?? minLoops) <= minLoops ||
23
+ ((particle.size.maxLoops ?? minLoops) > minLoops &&
24
+ (particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
24
25
  }
25
26
  reset(particle) {
26
- particle.size.loops = 0;
27
+ particle.size.loops = minLoops;
27
28
  }
28
29
  update(particle, delta) {
29
30
  if (!this.isEnabled(particle)) {
30
31
  return;
31
32
  }
32
- (0, Utils_js_1.updateSize)(particle, delta);
33
+ (0, engine_1.updateAnimation)(particle, particle.size, true, particle.options.size.animation.destroy, delta);
33
34
  }
34
35
  }
35
36
  exports.SizeUpdater = SizeUpdater;
@@ -1,11 +1,11 @@
1
- import { getRandom } from "@tsparticles/engine";
2
- import { updateSize } from "./Utils.js";
1
+ import { getRandom, percentDenominator, updateAnimation, } from "@tsparticles/engine";
2
+ const minLoops = 0;
3
3
  export class SizeUpdater {
4
4
  init(particle) {
5
5
  const container = particle.container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
6
6
  if (sizeAnimation.enable) {
7
7
  particle.size.velocity =
8
- ((particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / 100) *
8
+ ((particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / percentDenominator) *
9
9
  container.retina.reduceFactor;
10
10
  if (!sizeAnimation.sync) {
11
11
  particle.size.velocity *= getRandom();
@@ -16,16 +16,17 @@ export class SizeUpdater {
16
16
  return (!particle.destroyed &&
17
17
  !particle.spawning &&
18
18
  particle.size.enable &&
19
- ((particle.size.maxLoops ?? 0) <= 0 ||
20
- ((particle.size.maxLoops ?? 0) > 0 && (particle.size.loops ?? 0) < (particle.size.maxLoops ?? 0))));
19
+ ((particle.size.maxLoops ?? minLoops) <= minLoops ||
20
+ ((particle.size.maxLoops ?? minLoops) > minLoops &&
21
+ (particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
21
22
  }
22
23
  reset(particle) {
23
- particle.size.loops = 0;
24
+ particle.size.loops = minLoops;
24
25
  }
25
26
  update(particle, delta) {
26
27
  if (!this.isEnabled(particle)) {
27
28
  return;
28
29
  }
29
- updateSize(particle, delta);
30
+ updateAnimation(particle, particle.size, true, particle.options.size.animation.destroy, delta);
30
31
  }
31
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/updater-size",
3
- "version": "3.0.3",
3
+ "version": "3.1.0",
4
4
  "description": "tsParticles particles size updater",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -87,7 +87,7 @@
87
87
  "./package.json": "./package.json"
88
88
  },
89
89
  "dependencies": {
90
- "@tsparticles/engine": "^3.0.3"
90
+ "@tsparticles/engine": "^3.1.0"
91
91
  },
92
92
  "publishConfig": {
93
93
  "access": "public"
package/report.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8"/>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
- <title>@tsparticles/updater-size [26 Dec 2023 at 19:32]</title>
6
+ <title>@tsparticles/updater-size [13 Jan 2024 at 23:09]</title>
7
7
  <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
8
8
 
9
9
  <script>
@@ -31,7 +31,7 @@
31
31
  <body>
32
32
  <div id="app"></div>
33
33
  <script>
34
- window.chartData = [{"label":"tsparticles.updater.size.js","isAsset":true,"statSize":2883,"parsedSize":6668,"gzipSize":2042,"groups":[{"label":"dist/browser","path":"./dist/browser","statSize":2841,"groups":[{"id":636,"label":"index.js + 2 modules (concatenated)","path":"./dist/browser/index.js + 2 modules (concatenated)","statSize":2841,"parsedSize":6668,"gzipSize":2042,"concatenated":true,"groups":[{"label":"dist/browser","path":"./dist/browser/index.js + 2 modules (concatenated)/dist/browser","statSize":2841,"groups":[{"id":null,"label":"index.js","path":"./dist/browser/index.js + 2 modules (concatenated)/dist/browser/index.js","statSize":190,"parsedSize":445,"gzipSize":136,"inaccurateSizes":true},{"id":null,"label":"SizeUpdater.js","path":"./dist/browser/index.js + 2 modules (concatenated)/dist/browser/SizeUpdater.js","statSize":963,"parsedSize":2260,"gzipSize":692,"inaccurateSizes":true},{"id":null,"label":"Utils.js","path":"./dist/browser/index.js + 2 modules (concatenated)/dist/browser/Utils.js","statSize":1688,"parsedSize":3961,"gzipSize":1213,"inaccurateSizes":true}],"parsedSize":6668,"gzipSize":2042,"inaccurateSizes":true}]}],"parsedSize":6668,"gzipSize":2042},{"label":"engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","statSize":42,"groups":[{"id":533,"label":"engine\",\"root\":\"window\"}","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles/engine\",\"root\":\"window\"}","statSize":42}],"parsedSize":0,"gzipSize":0}],"isInitialByEntrypoint":{"tsparticles.updater.size":true}}];
34
+ window.chartData = [{"label":"tsparticles.updater.size.js","isAsset":true,"statSize":1342,"parsedSize":5151,"gzipSize":1703,"groups":[{"label":"dist/browser","path":"./dist/browser","statSize":1300,"groups":[{"id":826,"label":"index.js + 1 modules (concatenated)","path":"./dist/browser/index.js + 1 modules (concatenated)","statSize":1300,"parsedSize":5151,"gzipSize":1703,"concatenated":true,"groups":[{"label":"dist/browser","path":"./dist/browser/index.js + 1 modules (concatenated)/dist/browser","statSize":1300,"groups":[{"id":null,"label":"index.js","path":"./dist/browser/index.js + 1 modules (concatenated)/dist/browser/index.js","statSize":190,"parsedSize":752,"gzipSize":248,"inaccurateSizes":true},{"id":null,"label":"SizeUpdater.js","path":"./dist/browser/index.js + 1 modules (concatenated)/dist/browser/SizeUpdater.js","statSize":1110,"parsedSize":4398,"gzipSize":1454,"inaccurateSizes":true}],"parsedSize":5151,"gzipSize":1703,"inaccurateSizes":true}]}],"parsedSize":5151,"gzipSize":1703},{"label":"engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","statSize":42,"groups":[{"id":533,"label":"engine\",\"root\":\"window\"}","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles/engine\",\"root\":\"window\"}","statSize":42}],"parsedSize":0,"gzipSize":0}],"isInitialByEntrypoint":{"tsparticles.updater.size":true}}];
35
35
  window.entrypoints = ["tsparticles.updater.size","tsparticles.updater.size.min"];
36
36
  window.defaultSizes = "parsed";
37
37
  </script>
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v3.0.3
7
+ * v3.1.0
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -96,97 +96,32 @@ __webpack_require__.d(__webpack_exports__, {
96
96
 
97
97
  // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
98
98
  var engine_root_window_ = __webpack_require__(533);
99
- ;// CONCATENATED MODULE: ./dist/browser/Utils.js
100
-
101
- function checkDestroy(particle, value, minValue, maxValue) {
102
- switch (particle.options.size.animation.destroy) {
103
- case "max":
104
- if (value >= maxValue) {
105
- particle.destroy();
106
- }
107
- break;
108
- case "min":
109
- if (value <= minValue) {
110
- particle.destroy();
111
- }
112
- break;
113
- }
114
- }
115
- function updateSize(particle, delta) {
116
- const data = particle.size;
117
- if (particle.destroyed || !data || !data.enable || (data.maxLoops ?? 0) > 0 && (data.loops ?? 0) > (data.maxLoops ?? 0)) {
118
- return;
119
- }
120
- const sizeVelocity = (data.velocity ?? 0) * delta.factor,
121
- minValue = data.min,
122
- maxValue = data.max,
123
- decay = data.decay ?? 1;
124
- if (!data.time) {
125
- data.time = 0;
126
- }
127
- if ((data.delayTime ?? 0) > 0 && data.time < (data.delayTime ?? 0)) {
128
- data.time += delta.value;
129
- }
130
- if ((data.delayTime ?? 0) > 0 && data.time < (data.delayTime ?? 0)) {
131
- return;
132
- }
133
- switch (data.status) {
134
- case "increasing":
135
- if (data.value >= maxValue) {
136
- data.status = "decreasing";
137
- if (!data.loops) {
138
- data.loops = 0;
139
- }
140
- data.loops++;
141
- } else {
142
- data.value += sizeVelocity;
143
- }
144
- break;
145
- case "decreasing":
146
- if (data.value <= minValue) {
147
- data.status = "increasing";
148
- if (!data.loops) {
149
- data.loops = 0;
150
- }
151
- data.loops++;
152
- } else {
153
- data.value -= sizeVelocity;
154
- }
155
- }
156
- if (data.velocity && decay !== 1) {
157
- data.velocity *= decay;
158
- }
159
- checkDestroy(particle, data.value, minValue, maxValue);
160
- if (!particle.destroyed) {
161
- data.value = (0,engine_root_window_.clamp)(data.value, minValue, maxValue);
162
- }
163
- }
164
99
  ;// CONCATENATED MODULE: ./dist/browser/SizeUpdater.js
165
100
 
166
-
101
+ const minLoops = 0;
167
102
  class SizeUpdater {
168
103
  init(particle) {
169
104
  const container = particle.container,
170
105
  sizeOptions = particle.options.size,
171
106
  sizeAnimation = sizeOptions.animation;
172
107
  if (sizeAnimation.enable) {
173
- particle.size.velocity = (particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / 100 * container.retina.reduceFactor;
108
+ particle.size.velocity = (particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / engine_root_window_.percentDenominator * container.retina.reduceFactor;
174
109
  if (!sizeAnimation.sync) {
175
110
  particle.size.velocity *= (0,engine_root_window_.getRandom)();
176
111
  }
177
112
  }
178
113
  }
179
114
  isEnabled(particle) {
180
- return !particle.destroyed && !particle.spawning && particle.size.enable && ((particle.size.maxLoops ?? 0) <= 0 || (particle.size.maxLoops ?? 0) > 0 && (particle.size.loops ?? 0) < (particle.size.maxLoops ?? 0));
115
+ return !particle.destroyed && !particle.spawning && particle.size.enable && ((particle.size.maxLoops ?? minLoops) <= minLoops || (particle.size.maxLoops ?? minLoops) > minLoops && (particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops));
181
116
  }
182
117
  reset(particle) {
183
- particle.size.loops = 0;
118
+ particle.size.loops = minLoops;
184
119
  }
185
120
  update(particle, delta) {
186
121
  if (!this.isEnabled(particle)) {
187
122
  return;
188
123
  }
189
- updateSize(particle, delta);
124
+ (0,engine_root_window_.updateAnimation)(particle, particle.size, true, particle.options.size.animation.destroy, delta);
190
125
  }
191
126
  }
192
127
  ;// CONCATENATED MODULE: ./dist/browser/index.js
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.updater.size.min.js.LICENSE.txt */
2
- !function(e,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],o);else{var t="object"==typeof exports?o(require("@tsparticles/engine")):o(e.window);for(var i in t)("object"==typeof exports?exports:e)[i]=t[i]}}(this,(e=>(()=>{"use strict";var o={533:o=>{o.exports=e}},t={};function i(e){var s=t[e];if(void 0!==s)return s.exports;var a=t[e]={exports:{}};return o[e](a,a.exports,i),a.exports}i.d=(e,o)=>{for(var t in o)i.o(o,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:o[t]})},i.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return(()=>{i.r(s),i.d(s,{loadSizeUpdater:()=>t});var e=i(533);class o{init(o){const t=o.container,i=o.options.size.animation;i.enable&&(o.size.velocity=(o.retina.sizeAnimationSpeed??t.retina.sizeAnimationSpeed)/100*t.retina.reduceFactor,i.sync||(o.size.velocity*=(0,e.getRandom)()))}isEnabled(e){return!e.destroyed&&!e.spawning&&e.size.enable&&((e.size.maxLoops??0)<=0||(e.size.maxLoops??0)>0&&(e.size.loops??0)<(e.size.maxLoops??0))}reset(e){e.size.loops=0}update(o,t){this.isEnabled(o)&&function(o,t){const i=o.size;if(o.destroyed||!i||!i.enable||(i.maxLoops??0)>0&&(i.loops??0)>(i.maxLoops??0))return;const s=(i.velocity??0)*t.factor,a=i.min,n=i.max,r=i.decay??1;if(i.time||(i.time=0),(i.delayTime??0)>0&&i.time<(i.delayTime??0)&&(i.time+=t.value),!((i.delayTime??0)>0&&i.time<(i.delayTime??0))){switch(i.status){case"increasing":i.value>=n?(i.status="decreasing",i.loops||(i.loops=0),i.loops++):i.value+=s;break;case"decreasing":i.value<=a?(i.status="increasing",i.loops||(i.loops=0),i.loops++):i.value-=s}i.velocity&&1!==r&&(i.velocity*=r),function(e,o,t,i){switch(e.options.size.animation.destroy){case"max":o>=i&&e.destroy();break;case"min":o<=t&&e.destroy()}}(o,i.value,a,n),o.destroyed||(i.value=(0,e.clamp)(i.value,a,n))}}(o,t)}}async function t(e,t=!0){await e.addParticleUpdater("size",(()=>new o),t)}})(),s})()));
2
+ !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 i in o)("object"==typeof exports?exports:e)[i]=o[i]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},o={};function i(e){var n=o[e];if(void 0!==n)return n.exports;var r=o[e]={exports:{}};return t[e](r,r.exports,i),r.exports}i.d=(e,t)=>{for(var o in t)i.o(t,o)&&!i.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{i.r(n),i.d(n,{loadSizeUpdater:()=>o});var e=i(533);class t{init(t){const o=t.container,i=t.options.size.animation;i.enable&&(t.size.velocity=(t.retina.sizeAnimationSpeed??o.retina.sizeAnimationSpeed)/e.percentDenominator*o.retina.reduceFactor,i.sync||(t.size.velocity*=(0,e.getRandom)()))}isEnabled(e){return!e.destroyed&&!e.spawning&&e.size.enable&&((e.size.maxLoops??0)<=0||(e.size.maxLoops??0)>0&&(e.size.loops??0)<(e.size.maxLoops??0))}reset(e){e.size.loops=0}update(t,o){this.isEnabled(t)&&(0,e.updateAnimation)(t,t.size,!0,t.options.size.animation.destroy,o)}}async function o(e,o=!0){await e.addParticleUpdater("size",(()=>new t),o)}})(),n})()));
@@ -1 +1 @@
1
- /*! tsParticles Size Updater v3.0.3 by Matteo Bruni */
1
+ /*! tsParticles Size Updater v3.1.0 by Matteo Bruni */
@@ -4,20 +4,20 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine", "./Utils.js"], factory);
7
+ define(["require", "exports", "@tsparticles/engine"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SizeUpdater = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
- const Utils_js_1 = require("./Utils.js");
14
+ const minLoops = 0;
15
15
  class SizeUpdater {
16
16
  init(particle) {
17
17
  const container = particle.container, sizeOptions = particle.options.size, sizeAnimation = sizeOptions.animation;
18
18
  if (sizeAnimation.enable) {
19
19
  particle.size.velocity =
20
- ((particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / 100) *
20
+ ((particle.retina.sizeAnimationSpeed ?? container.retina.sizeAnimationSpeed) / engine_1.percentDenominator) *
21
21
  container.retina.reduceFactor;
22
22
  if (!sizeAnimation.sync) {
23
23
  particle.size.velocity *= (0, engine_1.getRandom)();
@@ -28,17 +28,18 @@
28
28
  return (!particle.destroyed &&
29
29
  !particle.spawning &&
30
30
  particle.size.enable &&
31
- ((particle.size.maxLoops ?? 0) <= 0 ||
32
- ((particle.size.maxLoops ?? 0) > 0 && (particle.size.loops ?? 0) < (particle.size.maxLoops ?? 0))));
31
+ ((particle.size.maxLoops ?? minLoops) <= minLoops ||
32
+ ((particle.size.maxLoops ?? minLoops) > minLoops &&
33
+ (particle.size.loops ?? minLoops) < (particle.size.maxLoops ?? minLoops))));
33
34
  }
34
35
  reset(particle) {
35
- particle.size.loops = 0;
36
+ particle.size.loops = minLoops;
36
37
  }
37
38
  update(particle, delta) {
38
39
  if (!this.isEnabled(particle)) {
39
40
  return;
40
41
  }
41
- (0, Utils_js_1.updateSize)(particle, delta);
42
+ (0, engine_1.updateAnimation)(particle, particle.size, true, particle.options.size.animation.destroy, delta);
42
43
  }
43
44
  }
44
45
  exports.SizeUpdater = SizeUpdater;
package/browser/Utils.js DELETED
@@ -1,66 +0,0 @@
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/cjs/Utils.js DELETED
@@ -1,70 +0,0 @@
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/esm/Utils.js DELETED
@@ -1,66 +0,0 @@
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/types/Utils.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { type IDelta, type Particle } from "@tsparticles/engine";
2
- export declare function updateSize(particle: Particle, delta: IDelta): void;
package/umd/Utils.js DELETED
@@ -1,80 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.updateSize = void 0;
13
- const engine_1 = require("@tsparticles/engine");
14
- function checkDestroy(particle, value, minValue, maxValue) {
15
- switch (particle.options.size.animation.destroy) {
16
- case "max":
17
- if (value >= maxValue) {
18
- particle.destroy();
19
- }
20
- break;
21
- case "min":
22
- if (value <= minValue) {
23
- particle.destroy();
24
- }
25
- break;
26
- }
27
- }
28
- function updateSize(particle, delta) {
29
- const data = particle.size;
30
- if (particle.destroyed ||
31
- !data ||
32
- !data.enable ||
33
- ((data.maxLoops ?? 0) > 0 && (data.loops ?? 0) > (data.maxLoops ?? 0))) {
34
- return;
35
- }
36
- const sizeVelocity = (data.velocity ?? 0) * delta.factor, minValue = data.min, maxValue = data.max, decay = data.decay ?? 1;
37
- if (!data.time) {
38
- data.time = 0;
39
- }
40
- if ((data.delayTime ?? 0) > 0 && data.time < (data.delayTime ?? 0)) {
41
- data.time += delta.value;
42
- }
43
- if ((data.delayTime ?? 0) > 0 && data.time < (data.delayTime ?? 0)) {
44
- return;
45
- }
46
- switch (data.status) {
47
- case "increasing":
48
- if (data.value >= maxValue) {
49
- data.status = "decreasing";
50
- if (!data.loops) {
51
- data.loops = 0;
52
- }
53
- data.loops++;
54
- }
55
- else {
56
- data.value += sizeVelocity;
57
- }
58
- break;
59
- case "decreasing":
60
- if (data.value <= minValue) {
61
- data.status = "increasing";
62
- if (!data.loops) {
63
- data.loops = 0;
64
- }
65
- data.loops++;
66
- }
67
- else {
68
- data.value -= sizeVelocity;
69
- }
70
- }
71
- if (data.velocity && decay !== 1) {
72
- data.velocity *= decay;
73
- }
74
- checkDestroy(particle, data.value, minValue, maxValue);
75
- if (!particle.destroyed) {
76
- data.value = (0, engine_1.clamp)(data.value, minValue, maxValue);
77
- }
78
- }
79
- exports.updateSize = updateSize;
80
- });