@tsparticles/updater-life 3.0.2 → 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.
- package/browser/LifeUpdater.js +27 -26
- package/cjs/LifeUpdater.js +26 -25
- package/esm/LifeUpdater.js +27 -26
- package/package.json +2 -2
- package/report.html +2 -2
- package/tsparticles.updater.life.js +28 -23
- package/tsparticles.updater.life.min.js +1 -1
- package/tsparticles.updater.life.min.js.LICENSE.txt +1 -1
- package/umd/LifeUpdater.js +26 -25
package/browser/LifeUpdater.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { getRandom, getRangeValue, randomInRange, setRangeValue, } from "@tsparticles/engine";
|
|
1
|
+
import { getRandom, getRangeValue, millisecondsToSeconds, randomInRange, setRangeValue, } from "@tsparticles/engine";
|
|
2
2
|
import { Life } from "./Options/Classes/Life.js";
|
|
3
|
+
const noTime = 0, identity = 1, infiniteValue = -1, noLife = 0, minCanvasSize = 0;
|
|
3
4
|
export class LifeUpdater {
|
|
4
5
|
constructor(container) {
|
|
5
6
|
this.container = container;
|
|
@@ -11,27 +12,27 @@ export class LifeUpdater {
|
|
|
11
12
|
}
|
|
12
13
|
particle.life = {
|
|
13
14
|
delay: container.retina.reduceFactor
|
|
14
|
-
? ((getRangeValue(lifeOptions.delay.value) * (lifeOptions.delay.sync ?
|
|
15
|
+
? ((getRangeValue(lifeOptions.delay.value) * (lifeOptions.delay.sync ? identity : getRandom())) /
|
|
15
16
|
container.retina.reduceFactor) *
|
|
16
|
-
|
|
17
|
-
:
|
|
18
|
-
delayTime:
|
|
17
|
+
millisecondsToSeconds
|
|
18
|
+
: noTime,
|
|
19
|
+
delayTime: noTime,
|
|
19
20
|
duration: container.retina.reduceFactor
|
|
20
|
-
? ((getRangeValue(lifeOptions.duration.value) * (lifeOptions.duration.sync ?
|
|
21
|
+
? ((getRangeValue(lifeOptions.duration.value) * (lifeOptions.duration.sync ? identity : getRandom())) /
|
|
21
22
|
container.retina.reduceFactor) *
|
|
22
|
-
|
|
23
|
-
:
|
|
24
|
-
time:
|
|
23
|
+
millisecondsToSeconds
|
|
24
|
+
: noTime,
|
|
25
|
+
time: noTime,
|
|
25
26
|
count: lifeOptions.count,
|
|
26
27
|
};
|
|
27
|
-
if (particle.life.duration <=
|
|
28
|
-
particle.life.duration =
|
|
28
|
+
if (particle.life.duration <= noTime) {
|
|
29
|
+
particle.life.duration = infiniteValue;
|
|
29
30
|
}
|
|
30
|
-
if (particle.life.count <=
|
|
31
|
-
particle.life.count =
|
|
31
|
+
if (particle.life.count <= noTime) {
|
|
32
|
+
particle.life.count = infiniteValue;
|
|
32
33
|
}
|
|
33
34
|
if (particle.life) {
|
|
34
|
-
particle.spawning = particle.life.delay >
|
|
35
|
+
particle.spawning = particle.life.delay > noTime;
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
isEnabled(particle) {
|
|
@@ -56,21 +57,21 @@ export class LifeUpdater {
|
|
|
56
57
|
if (life.delayTime >= particle.life.delay) {
|
|
57
58
|
justSpawned = true;
|
|
58
59
|
particle.spawning = false;
|
|
59
|
-
life.delayTime =
|
|
60
|
-
life.time =
|
|
60
|
+
life.delayTime = noTime;
|
|
61
|
+
life.time = noTime;
|
|
61
62
|
}
|
|
62
63
|
else {
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
|
-
if (life.duration ===
|
|
67
|
+
if (life.duration === infiniteValue) {
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
69
70
|
if (particle.spawning) {
|
|
70
71
|
return;
|
|
71
72
|
}
|
|
72
73
|
if (justSpawned) {
|
|
73
|
-
life.time =
|
|
74
|
+
life.time = noTime;
|
|
74
75
|
}
|
|
75
76
|
else {
|
|
76
77
|
life.time += delta.value;
|
|
@@ -78,25 +79,25 @@ export class LifeUpdater {
|
|
|
78
79
|
if (life.time < life.duration) {
|
|
79
80
|
return;
|
|
80
81
|
}
|
|
81
|
-
life.time =
|
|
82
|
-
if (particle.life.count >
|
|
82
|
+
life.time = noTime;
|
|
83
|
+
if (particle.life.count > noLife) {
|
|
83
84
|
particle.life.count--;
|
|
84
85
|
}
|
|
85
|
-
if (particle.life.count ===
|
|
86
|
+
if (particle.life.count === noLife) {
|
|
86
87
|
particle.destroy();
|
|
87
88
|
return;
|
|
88
89
|
}
|
|
89
|
-
const canvasSize = this.container.canvas.size, widthRange = setRangeValue(
|
|
90
|
+
const canvasSize = this.container.canvas.size, widthRange = setRangeValue(minCanvasSize, canvasSize.width), heightRange = setRangeValue(minCanvasSize, canvasSize.width);
|
|
90
91
|
particle.position.x = randomInRange(widthRange);
|
|
91
92
|
particle.position.y = randomInRange(heightRange);
|
|
92
93
|
particle.spawning = true;
|
|
93
|
-
life.delayTime =
|
|
94
|
-
life.time =
|
|
94
|
+
life.delayTime = noTime;
|
|
95
|
+
life.time = noTime;
|
|
95
96
|
particle.reset();
|
|
96
97
|
const lifeOptions = particle.options.life;
|
|
97
98
|
if (lifeOptions) {
|
|
98
|
-
life.delay = getRangeValue(lifeOptions.delay.value) *
|
|
99
|
-
life.duration = getRangeValue(lifeOptions.duration.value) *
|
|
99
|
+
life.delay = getRangeValue(lifeOptions.delay.value) * millisecondsToSeconds;
|
|
100
|
+
life.duration = getRangeValue(lifeOptions.duration.value) * millisecondsToSeconds;
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
}
|
package/cjs/LifeUpdater.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LifeUpdater = void 0;
|
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
5
|
const Life_js_1 = require("./Options/Classes/Life.js");
|
|
6
|
+
const noTime = 0, identity = 1, infiniteValue = -1, noLife = 0, minCanvasSize = 0;
|
|
6
7
|
class LifeUpdater {
|
|
7
8
|
constructor(container) {
|
|
8
9
|
this.container = container;
|
|
@@ -14,27 +15,27 @@ class LifeUpdater {
|
|
|
14
15
|
}
|
|
15
16
|
particle.life = {
|
|
16
17
|
delay: container.retina.reduceFactor
|
|
17
|
-
? (((0, engine_1.getRangeValue)(lifeOptions.delay.value) * (lifeOptions.delay.sync ?
|
|
18
|
+
? (((0, engine_1.getRangeValue)(lifeOptions.delay.value) * (lifeOptions.delay.sync ? identity : (0, engine_1.getRandom)())) /
|
|
18
19
|
container.retina.reduceFactor) *
|
|
19
|
-
|
|
20
|
-
:
|
|
21
|
-
delayTime:
|
|
20
|
+
engine_1.millisecondsToSeconds
|
|
21
|
+
: noTime,
|
|
22
|
+
delayTime: noTime,
|
|
22
23
|
duration: container.retina.reduceFactor
|
|
23
|
-
? (((0, engine_1.getRangeValue)(lifeOptions.duration.value) * (lifeOptions.duration.sync ?
|
|
24
|
+
? (((0, engine_1.getRangeValue)(lifeOptions.duration.value) * (lifeOptions.duration.sync ? identity : (0, engine_1.getRandom)())) /
|
|
24
25
|
container.retina.reduceFactor) *
|
|
25
|
-
|
|
26
|
-
:
|
|
27
|
-
time:
|
|
26
|
+
engine_1.millisecondsToSeconds
|
|
27
|
+
: noTime,
|
|
28
|
+
time: noTime,
|
|
28
29
|
count: lifeOptions.count,
|
|
29
30
|
};
|
|
30
|
-
if (particle.life.duration <=
|
|
31
|
-
particle.life.duration =
|
|
31
|
+
if (particle.life.duration <= noTime) {
|
|
32
|
+
particle.life.duration = infiniteValue;
|
|
32
33
|
}
|
|
33
|
-
if (particle.life.count <=
|
|
34
|
-
particle.life.count =
|
|
34
|
+
if (particle.life.count <= noTime) {
|
|
35
|
+
particle.life.count = infiniteValue;
|
|
35
36
|
}
|
|
36
37
|
if (particle.life) {
|
|
37
|
-
particle.spawning = particle.life.delay >
|
|
38
|
+
particle.spawning = particle.life.delay > noTime;
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
isEnabled(particle) {
|
|
@@ -59,21 +60,21 @@ class LifeUpdater {
|
|
|
59
60
|
if (life.delayTime >= particle.life.delay) {
|
|
60
61
|
justSpawned = true;
|
|
61
62
|
particle.spawning = false;
|
|
62
|
-
life.delayTime =
|
|
63
|
-
life.time =
|
|
63
|
+
life.delayTime = noTime;
|
|
64
|
+
life.time = noTime;
|
|
64
65
|
}
|
|
65
66
|
else {
|
|
66
67
|
return;
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
|
-
if (life.duration ===
|
|
70
|
+
if (life.duration === infiniteValue) {
|
|
70
71
|
return;
|
|
71
72
|
}
|
|
72
73
|
if (particle.spawning) {
|
|
73
74
|
return;
|
|
74
75
|
}
|
|
75
76
|
if (justSpawned) {
|
|
76
|
-
life.time =
|
|
77
|
+
life.time = noTime;
|
|
77
78
|
}
|
|
78
79
|
else {
|
|
79
80
|
life.time += delta.value;
|
|
@@ -81,25 +82,25 @@ class LifeUpdater {
|
|
|
81
82
|
if (life.time < life.duration) {
|
|
82
83
|
return;
|
|
83
84
|
}
|
|
84
|
-
life.time =
|
|
85
|
-
if (particle.life.count >
|
|
85
|
+
life.time = noTime;
|
|
86
|
+
if (particle.life.count > noLife) {
|
|
86
87
|
particle.life.count--;
|
|
87
88
|
}
|
|
88
|
-
if (particle.life.count ===
|
|
89
|
+
if (particle.life.count === noLife) {
|
|
89
90
|
particle.destroy();
|
|
90
91
|
return;
|
|
91
92
|
}
|
|
92
|
-
const canvasSize = this.container.canvas.size, widthRange = (0, engine_1.setRangeValue)(
|
|
93
|
+
const canvasSize = this.container.canvas.size, widthRange = (0, engine_1.setRangeValue)(minCanvasSize, canvasSize.width), heightRange = (0, engine_1.setRangeValue)(minCanvasSize, canvasSize.width);
|
|
93
94
|
particle.position.x = (0, engine_1.randomInRange)(widthRange);
|
|
94
95
|
particle.position.y = (0, engine_1.randomInRange)(heightRange);
|
|
95
96
|
particle.spawning = true;
|
|
96
|
-
life.delayTime =
|
|
97
|
-
life.time =
|
|
97
|
+
life.delayTime = noTime;
|
|
98
|
+
life.time = noTime;
|
|
98
99
|
particle.reset();
|
|
99
100
|
const lifeOptions = particle.options.life;
|
|
100
101
|
if (lifeOptions) {
|
|
101
|
-
life.delay = (0, engine_1.getRangeValue)(lifeOptions.delay.value) *
|
|
102
|
-
life.duration = (0, engine_1.getRangeValue)(lifeOptions.duration.value) *
|
|
102
|
+
life.delay = (0, engine_1.getRangeValue)(lifeOptions.delay.value) * engine_1.millisecondsToSeconds;
|
|
103
|
+
life.duration = (0, engine_1.getRangeValue)(lifeOptions.duration.value) * engine_1.millisecondsToSeconds;
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
}
|
package/esm/LifeUpdater.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { getRandom, getRangeValue, randomInRange, setRangeValue, } from "@tsparticles/engine";
|
|
1
|
+
import { getRandom, getRangeValue, millisecondsToSeconds, randomInRange, setRangeValue, } from "@tsparticles/engine";
|
|
2
2
|
import { Life } from "./Options/Classes/Life.js";
|
|
3
|
+
const noTime = 0, identity = 1, infiniteValue = -1, noLife = 0, minCanvasSize = 0;
|
|
3
4
|
export class LifeUpdater {
|
|
4
5
|
constructor(container) {
|
|
5
6
|
this.container = container;
|
|
@@ -11,27 +12,27 @@ export class LifeUpdater {
|
|
|
11
12
|
}
|
|
12
13
|
particle.life = {
|
|
13
14
|
delay: container.retina.reduceFactor
|
|
14
|
-
? ((getRangeValue(lifeOptions.delay.value) * (lifeOptions.delay.sync ?
|
|
15
|
+
? ((getRangeValue(lifeOptions.delay.value) * (lifeOptions.delay.sync ? identity : getRandom())) /
|
|
15
16
|
container.retina.reduceFactor) *
|
|
16
|
-
|
|
17
|
-
:
|
|
18
|
-
delayTime:
|
|
17
|
+
millisecondsToSeconds
|
|
18
|
+
: noTime,
|
|
19
|
+
delayTime: noTime,
|
|
19
20
|
duration: container.retina.reduceFactor
|
|
20
|
-
? ((getRangeValue(lifeOptions.duration.value) * (lifeOptions.duration.sync ?
|
|
21
|
+
? ((getRangeValue(lifeOptions.duration.value) * (lifeOptions.duration.sync ? identity : getRandom())) /
|
|
21
22
|
container.retina.reduceFactor) *
|
|
22
|
-
|
|
23
|
-
:
|
|
24
|
-
time:
|
|
23
|
+
millisecondsToSeconds
|
|
24
|
+
: noTime,
|
|
25
|
+
time: noTime,
|
|
25
26
|
count: lifeOptions.count,
|
|
26
27
|
};
|
|
27
|
-
if (particle.life.duration <=
|
|
28
|
-
particle.life.duration =
|
|
28
|
+
if (particle.life.duration <= noTime) {
|
|
29
|
+
particle.life.duration = infiniteValue;
|
|
29
30
|
}
|
|
30
|
-
if (particle.life.count <=
|
|
31
|
-
particle.life.count =
|
|
31
|
+
if (particle.life.count <= noTime) {
|
|
32
|
+
particle.life.count = infiniteValue;
|
|
32
33
|
}
|
|
33
34
|
if (particle.life) {
|
|
34
|
-
particle.spawning = particle.life.delay >
|
|
35
|
+
particle.spawning = particle.life.delay > noTime;
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
isEnabled(particle) {
|
|
@@ -56,21 +57,21 @@ export class LifeUpdater {
|
|
|
56
57
|
if (life.delayTime >= particle.life.delay) {
|
|
57
58
|
justSpawned = true;
|
|
58
59
|
particle.spawning = false;
|
|
59
|
-
life.delayTime =
|
|
60
|
-
life.time =
|
|
60
|
+
life.delayTime = noTime;
|
|
61
|
+
life.time = noTime;
|
|
61
62
|
}
|
|
62
63
|
else {
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
|
-
if (life.duration ===
|
|
67
|
+
if (life.duration === infiniteValue) {
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
69
70
|
if (particle.spawning) {
|
|
70
71
|
return;
|
|
71
72
|
}
|
|
72
73
|
if (justSpawned) {
|
|
73
|
-
life.time =
|
|
74
|
+
life.time = noTime;
|
|
74
75
|
}
|
|
75
76
|
else {
|
|
76
77
|
life.time += delta.value;
|
|
@@ -78,25 +79,25 @@ export class LifeUpdater {
|
|
|
78
79
|
if (life.time < life.duration) {
|
|
79
80
|
return;
|
|
80
81
|
}
|
|
81
|
-
life.time =
|
|
82
|
-
if (particle.life.count >
|
|
82
|
+
life.time = noTime;
|
|
83
|
+
if (particle.life.count > noLife) {
|
|
83
84
|
particle.life.count--;
|
|
84
85
|
}
|
|
85
|
-
if (particle.life.count ===
|
|
86
|
+
if (particle.life.count === noLife) {
|
|
86
87
|
particle.destroy();
|
|
87
88
|
return;
|
|
88
89
|
}
|
|
89
|
-
const canvasSize = this.container.canvas.size, widthRange = setRangeValue(
|
|
90
|
+
const canvasSize = this.container.canvas.size, widthRange = setRangeValue(minCanvasSize, canvasSize.width), heightRange = setRangeValue(minCanvasSize, canvasSize.width);
|
|
90
91
|
particle.position.x = randomInRange(widthRange);
|
|
91
92
|
particle.position.y = randomInRange(heightRange);
|
|
92
93
|
particle.spawning = true;
|
|
93
|
-
life.delayTime =
|
|
94
|
-
life.time =
|
|
94
|
+
life.delayTime = noTime;
|
|
95
|
+
life.time = noTime;
|
|
95
96
|
particle.reset();
|
|
96
97
|
const lifeOptions = particle.options.life;
|
|
97
98
|
if (lifeOptions) {
|
|
98
|
-
life.delay = getRangeValue(lifeOptions.delay.value) *
|
|
99
|
-
life.duration = getRangeValue(lifeOptions.duration.value) *
|
|
99
|
+
life.delay = getRangeValue(lifeOptions.delay.value) * millisecondsToSeconds;
|
|
100
|
+
life.duration = getRangeValue(lifeOptions.duration.value) * millisecondsToSeconds;
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/updater-life",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "tsParticles particles life 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
|
|
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-life [
|
|
6
|
+
<title>@tsparticles/updater-life [13 Jan 2024 at 23:08]</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.life.js","isAsset":true,"statSize":
|
|
34
|
+
window.chartData = [{"label":"tsparticles.updater.life.js","isAsset":true,"statSize":4438,"parsedSize":8446,"gzipSize":2253,"groups":[{"label":"dist/browser","path":"./dist/browser","statSize":4396,"groups":[{"id":465,"label":"index.js + 4 modules (concatenated)","path":"./dist/browser/index.js + 4 modules (concatenated)","statSize":4396,"parsedSize":8446,"gzipSize":2253,"concatenated":true,"groups":[{"label":"dist/browser","path":"./dist/browser/index.js + 4 modules (concatenated)/dist/browser","statSize":4396,"groups":[{"id":null,"label":"index.js","path":"./dist/browser/index.js + 4 modules (concatenated)/dist/browser/index.js","statSize":206,"parsedSize":395,"gzipSize":105,"inaccurateSizes":true},{"id":null,"label":"LifeUpdater.js","path":"./dist/browser/index.js + 4 modules (concatenated)/dist/browser/LifeUpdater.js","statSize":3133,"parsedSize":6019,"gzipSize":1605,"inaccurateSizes":true},{"label":"Options/Classes","path":"./dist/browser/index.js + 4 modules (concatenated)/dist/browser/Options/Classes","statSize":1057,"groups":[{"id":null,"label":"Life.js","path":"./dist/browser/index.js + 4 modules (concatenated)/dist/browser/Options/Classes/Life.js","statSize":432,"parsedSize":829,"gzipSize":221,"inaccurateSizes":true},{"id":null,"label":"LifeDelay.js","path":"./dist/browser/index.js + 4 modules (concatenated)/dist/browser/Options/Classes/LifeDelay.js","statSize":311,"parsedSize":597,"gzipSize":159,"inaccurateSizes":true},{"id":null,"label":"LifeDuration.js","path":"./dist/browser/index.js + 4 modules (concatenated)/dist/browser/Options/Classes/LifeDuration.js","statSize":314,"parsedSize":603,"gzipSize":160,"inaccurateSizes":true}],"parsedSize":2030,"gzipSize":541,"inaccurateSizes":true}],"parsedSize":8446,"gzipSize":2253,"inaccurateSizes":true}]}],"parsedSize":8446,"gzipSize":2253},{"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.life":true}}];
|
|
35
35
|
window.entrypoints = ["tsparticles.updater.life","tsparticles.updater.life.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
|
|
7
|
+
* v3.1.0
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -153,6 +153,11 @@ class Life {
|
|
|
153
153
|
;// CONCATENATED MODULE: ./dist/browser/LifeUpdater.js
|
|
154
154
|
|
|
155
155
|
|
|
156
|
+
const noTime = 0,
|
|
157
|
+
identity = 1,
|
|
158
|
+
infiniteValue = -1,
|
|
159
|
+
noLife = 0,
|
|
160
|
+
minCanvasSize = 0;
|
|
156
161
|
class LifeUpdater {
|
|
157
162
|
constructor(container) {
|
|
158
163
|
this.container = container;
|
|
@@ -165,20 +170,20 @@ class LifeUpdater {
|
|
|
165
170
|
return;
|
|
166
171
|
}
|
|
167
172
|
particle.life = {
|
|
168
|
-
delay: container.retina.reduceFactor ? (0,engine_root_window_.getRangeValue)(lifeOptions.delay.value) * (lifeOptions.delay.sync ?
|
|
169
|
-
delayTime:
|
|
170
|
-
duration: container.retina.reduceFactor ? (0,engine_root_window_.getRangeValue)(lifeOptions.duration.value) * (lifeOptions.duration.sync ?
|
|
171
|
-
time:
|
|
173
|
+
delay: container.retina.reduceFactor ? (0,engine_root_window_.getRangeValue)(lifeOptions.delay.value) * (lifeOptions.delay.sync ? identity : (0,engine_root_window_.getRandom)()) / container.retina.reduceFactor * engine_root_window_.millisecondsToSeconds : noTime,
|
|
174
|
+
delayTime: noTime,
|
|
175
|
+
duration: container.retina.reduceFactor ? (0,engine_root_window_.getRangeValue)(lifeOptions.duration.value) * (lifeOptions.duration.sync ? identity : (0,engine_root_window_.getRandom)()) / container.retina.reduceFactor * engine_root_window_.millisecondsToSeconds : noTime,
|
|
176
|
+
time: noTime,
|
|
172
177
|
count: lifeOptions.count
|
|
173
178
|
};
|
|
174
|
-
if (particle.life.duration <=
|
|
175
|
-
particle.life.duration =
|
|
179
|
+
if (particle.life.duration <= noTime) {
|
|
180
|
+
particle.life.duration = infiniteValue;
|
|
176
181
|
}
|
|
177
|
-
if (particle.life.count <=
|
|
178
|
-
particle.life.count =
|
|
182
|
+
if (particle.life.count <= noTime) {
|
|
183
|
+
particle.life.count = infiniteValue;
|
|
179
184
|
}
|
|
180
185
|
if (particle.life) {
|
|
181
|
-
particle.spawning = particle.life.delay >
|
|
186
|
+
particle.spawning = particle.life.delay > noTime;
|
|
182
187
|
}
|
|
183
188
|
}
|
|
184
189
|
isEnabled(particle) {
|
|
@@ -203,47 +208,47 @@ class LifeUpdater {
|
|
|
203
208
|
if (life.delayTime >= particle.life.delay) {
|
|
204
209
|
justSpawned = true;
|
|
205
210
|
particle.spawning = false;
|
|
206
|
-
life.delayTime =
|
|
207
|
-
life.time =
|
|
211
|
+
life.delayTime = noTime;
|
|
212
|
+
life.time = noTime;
|
|
208
213
|
} else {
|
|
209
214
|
return;
|
|
210
215
|
}
|
|
211
216
|
}
|
|
212
|
-
if (life.duration ===
|
|
217
|
+
if (life.duration === infiniteValue) {
|
|
213
218
|
return;
|
|
214
219
|
}
|
|
215
220
|
if (particle.spawning) {
|
|
216
221
|
return;
|
|
217
222
|
}
|
|
218
223
|
if (justSpawned) {
|
|
219
|
-
life.time =
|
|
224
|
+
life.time = noTime;
|
|
220
225
|
} else {
|
|
221
226
|
life.time += delta.value;
|
|
222
227
|
}
|
|
223
228
|
if (life.time < life.duration) {
|
|
224
229
|
return;
|
|
225
230
|
}
|
|
226
|
-
life.time =
|
|
227
|
-
if (particle.life.count >
|
|
231
|
+
life.time = noTime;
|
|
232
|
+
if (particle.life.count > noLife) {
|
|
228
233
|
particle.life.count--;
|
|
229
234
|
}
|
|
230
|
-
if (particle.life.count ===
|
|
235
|
+
if (particle.life.count === noLife) {
|
|
231
236
|
particle.destroy();
|
|
232
237
|
return;
|
|
233
238
|
}
|
|
234
239
|
const canvasSize = this.container.canvas.size,
|
|
235
|
-
widthRange = (0,engine_root_window_.setRangeValue)(
|
|
236
|
-
heightRange = (0,engine_root_window_.setRangeValue)(
|
|
240
|
+
widthRange = (0,engine_root_window_.setRangeValue)(minCanvasSize, canvasSize.width),
|
|
241
|
+
heightRange = (0,engine_root_window_.setRangeValue)(minCanvasSize, canvasSize.width);
|
|
237
242
|
particle.position.x = (0,engine_root_window_.randomInRange)(widthRange);
|
|
238
243
|
particle.position.y = (0,engine_root_window_.randomInRange)(heightRange);
|
|
239
244
|
particle.spawning = true;
|
|
240
|
-
life.delayTime =
|
|
241
|
-
life.time =
|
|
245
|
+
life.delayTime = noTime;
|
|
246
|
+
life.time = noTime;
|
|
242
247
|
particle.reset();
|
|
243
248
|
const lifeOptions = particle.options.life;
|
|
244
249
|
if (lifeOptions) {
|
|
245
|
-
life.delay = (0,engine_root_window_.getRangeValue)(lifeOptions.delay.value) *
|
|
246
|
-
life.duration = (0,engine_root_window_.getRangeValue)(lifeOptions.duration.value) *
|
|
250
|
+
life.delay = (0,engine_root_window_.getRangeValue)(lifeOptions.delay.value) * engine_root_window_.millisecondsToSeconds;
|
|
251
|
+
life.duration = (0,engine_root_window_.getRangeValue)(lifeOptions.duration.value) * engine_root_window_.millisecondsToSeconds;
|
|
247
252
|
}
|
|
248
253
|
}
|
|
249
254
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.updater.life.min.js.LICENSE.txt */
|
|
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 n="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},n={};function i(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,i),a.exports}i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},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 o={};return(()=>{i.r(o),i.d(o,{loadLifeUpdater:()=>s});var e=i(533);class t extends e.ValueWithRandom{constructor(){super(),this.sync=!1}load(e){e&&(super.load(e),void 0!==e.sync&&(this.sync=e.sync))}}class n extends e.ValueWithRandom{constructor(){super(),this.sync=!1}load(e){e&&(super.load(e),void 0!==e.sync&&(this.sync=e.sync))}}class a{constructor(){this.count=0,this.delay=new t,this.duration=new n}load(e){e&&(void 0!==e.count&&(this.count=e.count),this.delay.load(e.delay),this.duration.load(e.duration))}}class r{constructor(e){this.container=e}init(t){const n=this.container,i=t.options.life;i&&(t.life={delay:n.retina.reduceFactor?(0,e.getRangeValue)(i.delay.value)*(i.delay.sync?1:(0,e.getRandom)())/n.retina.reduceFactor*
|
|
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 n="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},n={};function i(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,i),a.exports}i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},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 o={};return(()=>{i.r(o),i.d(o,{loadLifeUpdater:()=>s});var e=i(533);class t extends e.ValueWithRandom{constructor(){super(),this.sync=!1}load(e){e&&(super.load(e),void 0!==e.sync&&(this.sync=e.sync))}}class n extends e.ValueWithRandom{constructor(){super(),this.sync=!1}load(e){e&&(super.load(e),void 0!==e.sync&&(this.sync=e.sync))}}class a{constructor(){this.count=0,this.delay=new t,this.duration=new n}load(e){e&&(void 0!==e.count&&(this.count=e.count),this.delay.load(e.delay),this.duration.load(e.duration))}}class r{constructor(e){this.container=e}init(t){const n=this.container,i=t.options.life;i&&(t.life={delay:n.retina.reduceFactor?(0,e.getRangeValue)(i.delay.value)*(i.delay.sync?1:(0,e.getRandom)())/n.retina.reduceFactor*e.millisecondsToSeconds:0,delayTime:0,duration:n.retina.reduceFactor?(0,e.getRangeValue)(i.duration.value)*(i.duration.sync?1:(0,e.getRandom)())/n.retina.reduceFactor*e.millisecondsToSeconds:0,time:0,count:i.count},t.life.duration<=0&&(t.life.duration=-1),t.life.count<=0&&(t.life.count=-1),t.life&&(t.spawning=t.life.delay>0))}isEnabled(e){return!e.destroyed}loadOptions(e,...t){e.life||(e.life=new a);for(const n of t)e.life.load(n?.life)}update(t,n){if(!this.isEnabled(t)||!t.life)return;const i=t.life;let o=!1;if(t.spawning){if(i.delayTime+=n.value,!(i.delayTime>=t.life.delay))return;o=!0,t.spawning=!1,i.delayTime=0,i.time=0}if(-1===i.duration)return;if(t.spawning)return;if(o?i.time=0:i.time+=n.value,i.time<i.duration)return;if(i.time=0,t.life.count>0&&t.life.count--,0===t.life.count)return void t.destroy();const a=this.container.canvas.size,r=(0,e.setRangeValue)(0,a.width),s=(0,e.setRangeValue)(0,a.width);t.position.x=(0,e.randomInRange)(r),t.position.y=(0,e.randomInRange)(s),t.spawning=!0,i.delayTime=0,i.time=0,t.reset();const l=t.options.life;l&&(i.delay=(0,e.getRangeValue)(l.delay.value)*e.millisecondsToSeconds,i.duration=(0,e.getRangeValue)(l.duration.value)*e.millisecondsToSeconds)}}async function s(e,t=!0){await e.addParticleUpdater("life",(e=>new r(e)),t)}})(),o})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Life Updater v3.0
|
|
1
|
+
/*! tsParticles Life Updater v3.1.0 by Matteo Bruni */
|
package/umd/LifeUpdater.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
exports.LifeUpdater = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
const Life_js_1 = require("./Options/Classes/Life.js");
|
|
15
|
+
const noTime = 0, identity = 1, infiniteValue = -1, noLife = 0, minCanvasSize = 0;
|
|
15
16
|
class LifeUpdater {
|
|
16
17
|
constructor(container) {
|
|
17
18
|
this.container = container;
|
|
@@ -23,27 +24,27 @@
|
|
|
23
24
|
}
|
|
24
25
|
particle.life = {
|
|
25
26
|
delay: container.retina.reduceFactor
|
|
26
|
-
? (((0, engine_1.getRangeValue)(lifeOptions.delay.value) * (lifeOptions.delay.sync ?
|
|
27
|
+
? (((0, engine_1.getRangeValue)(lifeOptions.delay.value) * (lifeOptions.delay.sync ? identity : (0, engine_1.getRandom)())) /
|
|
27
28
|
container.retina.reduceFactor) *
|
|
28
|
-
|
|
29
|
-
:
|
|
30
|
-
delayTime:
|
|
29
|
+
engine_1.millisecondsToSeconds
|
|
30
|
+
: noTime,
|
|
31
|
+
delayTime: noTime,
|
|
31
32
|
duration: container.retina.reduceFactor
|
|
32
|
-
? (((0, engine_1.getRangeValue)(lifeOptions.duration.value) * (lifeOptions.duration.sync ?
|
|
33
|
+
? (((0, engine_1.getRangeValue)(lifeOptions.duration.value) * (lifeOptions.duration.sync ? identity : (0, engine_1.getRandom)())) /
|
|
33
34
|
container.retina.reduceFactor) *
|
|
34
|
-
|
|
35
|
-
:
|
|
36
|
-
time:
|
|
35
|
+
engine_1.millisecondsToSeconds
|
|
36
|
+
: noTime,
|
|
37
|
+
time: noTime,
|
|
37
38
|
count: lifeOptions.count,
|
|
38
39
|
};
|
|
39
|
-
if (particle.life.duration <=
|
|
40
|
-
particle.life.duration =
|
|
40
|
+
if (particle.life.duration <= noTime) {
|
|
41
|
+
particle.life.duration = infiniteValue;
|
|
41
42
|
}
|
|
42
|
-
if (particle.life.count <=
|
|
43
|
-
particle.life.count =
|
|
43
|
+
if (particle.life.count <= noTime) {
|
|
44
|
+
particle.life.count = infiniteValue;
|
|
44
45
|
}
|
|
45
46
|
if (particle.life) {
|
|
46
|
-
particle.spawning = particle.life.delay >
|
|
47
|
+
particle.spawning = particle.life.delay > noTime;
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
isEnabled(particle) {
|
|
@@ -68,21 +69,21 @@
|
|
|
68
69
|
if (life.delayTime >= particle.life.delay) {
|
|
69
70
|
justSpawned = true;
|
|
70
71
|
particle.spawning = false;
|
|
71
|
-
life.delayTime =
|
|
72
|
-
life.time =
|
|
72
|
+
life.delayTime = noTime;
|
|
73
|
+
life.time = noTime;
|
|
73
74
|
}
|
|
74
75
|
else {
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
|
-
if (life.duration ===
|
|
79
|
+
if (life.duration === infiniteValue) {
|
|
79
80
|
return;
|
|
80
81
|
}
|
|
81
82
|
if (particle.spawning) {
|
|
82
83
|
return;
|
|
83
84
|
}
|
|
84
85
|
if (justSpawned) {
|
|
85
|
-
life.time =
|
|
86
|
+
life.time = noTime;
|
|
86
87
|
}
|
|
87
88
|
else {
|
|
88
89
|
life.time += delta.value;
|
|
@@ -90,25 +91,25 @@
|
|
|
90
91
|
if (life.time < life.duration) {
|
|
91
92
|
return;
|
|
92
93
|
}
|
|
93
|
-
life.time =
|
|
94
|
-
if (particle.life.count >
|
|
94
|
+
life.time = noTime;
|
|
95
|
+
if (particle.life.count > noLife) {
|
|
95
96
|
particle.life.count--;
|
|
96
97
|
}
|
|
97
|
-
if (particle.life.count ===
|
|
98
|
+
if (particle.life.count === noLife) {
|
|
98
99
|
particle.destroy();
|
|
99
100
|
return;
|
|
100
101
|
}
|
|
101
|
-
const canvasSize = this.container.canvas.size, widthRange = (0, engine_1.setRangeValue)(
|
|
102
|
+
const canvasSize = this.container.canvas.size, widthRange = (0, engine_1.setRangeValue)(minCanvasSize, canvasSize.width), heightRange = (0, engine_1.setRangeValue)(minCanvasSize, canvasSize.width);
|
|
102
103
|
particle.position.x = (0, engine_1.randomInRange)(widthRange);
|
|
103
104
|
particle.position.y = (0, engine_1.randomInRange)(heightRange);
|
|
104
105
|
particle.spawning = true;
|
|
105
|
-
life.delayTime =
|
|
106
|
-
life.time =
|
|
106
|
+
life.delayTime = noTime;
|
|
107
|
+
life.time = noTime;
|
|
107
108
|
particle.reset();
|
|
108
109
|
const lifeOptions = particle.options.life;
|
|
109
110
|
if (lifeOptions) {
|
|
110
|
-
life.delay = (0, engine_1.getRangeValue)(lifeOptions.delay.value) *
|
|
111
|
-
life.duration = (0, engine_1.getRangeValue)(lifeOptions.duration.value) *
|
|
111
|
+
life.delay = (0, engine_1.getRangeValue)(lifeOptions.delay.value) * engine_1.millisecondsToSeconds;
|
|
112
|
+
life.duration = (0, engine_1.getRangeValue)(lifeOptions.duration.value) * engine_1.millisecondsToSeconds;
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
}
|