@tsparticles/updater-life 3.1.0 → 3.2.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/103.min.js +2 -0
- package/103.min.js.LICENSE.txt +1 -0
- package/16.min.js +2 -0
- package/16.min.js.LICENSE.txt +1 -0
- package/browser/LifeUpdater.js +7 -53
- package/browser/Utils.js +56 -0
- package/browser/index.js +4 -2
- package/cjs/LifeUpdater.js +29 -52
- package/cjs/Utils.js +60 -0
- package/cjs/index.js +27 -2
- package/dist_browser_LifeUpdater_js.js +60 -0
- package/dist_browser_Utils_js.js +30 -0
- package/esm/LifeUpdater.js +7 -53
- package/esm/Utils.js +56 -0
- package/esm/index.js +4 -2
- package/package.json +2 -2
- package/report.html +3 -3
- package/tsparticles.updater.life.js +241 -180
- package/tsparticles.updater.life.min.js +1 -1
- package/tsparticles.updater.life.min.js.LICENSE.txt +1 -1
- package/types/LifeUpdater.d.ts +2 -2
- package/types/Utils.d.ts +3 -0
- package/umd/LifeUpdater.js +30 -52
- package/umd/Utils.js +70 -0
- package/umd/index.js +29 -3
package/umd/LifeUpdater.js
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
+
}) : function(o, v) {
|
|
15
|
+
o["default"] = v;
|
|
16
|
+
});
|
|
17
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
|
+
if (mod && mod.__esModule) return mod;
|
|
19
|
+
var result = {};
|
|
20
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
__setModuleDefault(result, mod);
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
1
24
|
(function (factory) {
|
|
2
25
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
26
|
var v = factory(require, exports);
|
|
@@ -8,16 +31,17 @@
|
|
|
8
31
|
}
|
|
9
32
|
})(function (require, exports) {
|
|
10
33
|
"use strict";
|
|
34
|
+
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
11
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
36
|
exports.LifeUpdater = void 0;
|
|
13
37
|
const engine_1 = require("@tsparticles/engine");
|
|
14
38
|
const Life_js_1 = require("./Options/Classes/Life.js");
|
|
15
|
-
const noTime = 0, identity = 1, infiniteValue = -1
|
|
39
|
+
const noTime = 0, identity = 1, infiniteValue = -1;
|
|
16
40
|
class LifeUpdater {
|
|
17
41
|
constructor(container) {
|
|
18
42
|
this.container = container;
|
|
19
43
|
}
|
|
20
|
-
init(particle) {
|
|
44
|
+
async init(particle) {
|
|
21
45
|
const container = this.container, particlesOptions = particle.options, lifeOptions = particlesOptions.life;
|
|
22
46
|
if (!lifeOptions) {
|
|
23
47
|
return;
|
|
@@ -46,6 +70,7 @@
|
|
|
46
70
|
if (particle.life) {
|
|
47
71
|
particle.spawning = particle.life.delay > noTime;
|
|
48
72
|
}
|
|
73
|
+
await Promise.resolve();
|
|
49
74
|
}
|
|
50
75
|
isEnabled(particle) {
|
|
51
76
|
return !particle.destroyed;
|
|
@@ -58,59 +83,12 @@
|
|
|
58
83
|
options.life.load(source?.life);
|
|
59
84
|
}
|
|
60
85
|
}
|
|
61
|
-
update(particle, delta) {
|
|
86
|
+
async update(particle, delta) {
|
|
62
87
|
if (!this.isEnabled(particle) || !particle.life) {
|
|
63
88
|
return;
|
|
64
89
|
}
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
if (particle.spawning) {
|
|
68
|
-
life.delayTime += delta.value;
|
|
69
|
-
if (life.delayTime >= particle.life.delay) {
|
|
70
|
-
justSpawned = true;
|
|
71
|
-
particle.spawning = false;
|
|
72
|
-
life.delayTime = noTime;
|
|
73
|
-
life.time = noTime;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (life.duration === infiniteValue) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
if (particle.spawning) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (justSpawned) {
|
|
86
|
-
life.time = noTime;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
life.time += delta.value;
|
|
90
|
-
}
|
|
91
|
-
if (life.time < life.duration) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
life.time = noTime;
|
|
95
|
-
if (particle.life.count > noLife) {
|
|
96
|
-
particle.life.count--;
|
|
97
|
-
}
|
|
98
|
-
if (particle.life.count === noLife) {
|
|
99
|
-
particle.destroy();
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const canvasSize = this.container.canvas.size, widthRange = (0, engine_1.setRangeValue)(minCanvasSize, canvasSize.width), heightRange = (0, engine_1.setRangeValue)(minCanvasSize, canvasSize.width);
|
|
103
|
-
particle.position.x = (0, engine_1.randomInRange)(widthRange);
|
|
104
|
-
particle.position.y = (0, engine_1.randomInRange)(heightRange);
|
|
105
|
-
particle.spawning = true;
|
|
106
|
-
life.delayTime = noTime;
|
|
107
|
-
life.time = noTime;
|
|
108
|
-
particle.reset();
|
|
109
|
-
const lifeOptions = particle.options.life;
|
|
110
|
-
if (lifeOptions) {
|
|
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;
|
|
113
|
-
}
|
|
90
|
+
const { updateLife } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Utils.js"))) : new Promise((resolve_1, reject_1) => { require(["./Utils.js"], resolve_1, reject_1); }).then(__importStar));
|
|
91
|
+
updateLife(particle, delta, this.container.canvas.size);
|
|
114
92
|
}
|
|
115
93
|
}
|
|
116
94
|
exports.LifeUpdater = LifeUpdater;
|
package/umd/Utils.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
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.updateLife = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const noTime = 0, infiniteValue = -1, noLife = 0, minCanvasSize = 0;
|
|
15
|
+
function updateLife(particle, delta, canvasSize) {
|
|
16
|
+
if (!particle.life) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const life = particle.life;
|
|
20
|
+
let justSpawned = false;
|
|
21
|
+
if (particle.spawning) {
|
|
22
|
+
life.delayTime += delta.value;
|
|
23
|
+
if (life.delayTime >= particle.life.delay) {
|
|
24
|
+
justSpawned = true;
|
|
25
|
+
particle.spawning = false;
|
|
26
|
+
life.delayTime = noTime;
|
|
27
|
+
life.time = noTime;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (life.duration === infiniteValue) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (particle.spawning) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (justSpawned) {
|
|
40
|
+
life.time = noTime;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
life.time += delta.value;
|
|
44
|
+
}
|
|
45
|
+
if (life.time < life.duration) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
life.time = noTime;
|
|
49
|
+
if (particle.life.count > noLife) {
|
|
50
|
+
particle.life.count--;
|
|
51
|
+
}
|
|
52
|
+
if (particle.life.count === noLife) {
|
|
53
|
+
particle.destroy();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const widthRange = (0, engine_1.setRangeValue)(minCanvasSize, canvasSize.width), heightRange = (0, engine_1.setRangeValue)(minCanvasSize, canvasSize.width);
|
|
57
|
+
particle.position.x = (0, engine_1.randomInRange)(widthRange);
|
|
58
|
+
particle.position.y = (0, engine_1.randomInRange)(heightRange);
|
|
59
|
+
particle.spawning = true;
|
|
60
|
+
life.delayTime = noTime;
|
|
61
|
+
life.time = noTime;
|
|
62
|
+
particle.reset();
|
|
63
|
+
const lifeOptions = particle.options.life;
|
|
64
|
+
if (lifeOptions) {
|
|
65
|
+
life.delay = (0, engine_1.getRangeValue)(lifeOptions.delay.value) * engine_1.millisecondsToSeconds;
|
|
66
|
+
life.duration = (0, engine_1.getRangeValue)(lifeOptions.duration.value) * engine_1.millisecondsToSeconds;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.updateLife = updateLife;
|
|
70
|
+
});
|
package/umd/index.js
CHANGED
|
@@ -1,18 +1,44 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
+
}) : function(o, v) {
|
|
15
|
+
o["default"] = v;
|
|
16
|
+
});
|
|
17
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
|
+
if (mod && mod.__esModule) return mod;
|
|
19
|
+
var result = {};
|
|
20
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
__setModuleDefault(result, mod);
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
1
24
|
(function (factory) {
|
|
2
25
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
26
|
var v = factory(require, exports);
|
|
4
27
|
if (v !== undefined) module.exports = v;
|
|
5
28
|
}
|
|
6
29
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports"
|
|
30
|
+
define(["require", "exports"], factory);
|
|
8
31
|
}
|
|
9
32
|
})(function (require, exports) {
|
|
10
33
|
"use strict";
|
|
34
|
+
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
11
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
36
|
exports.loadLifeUpdater = void 0;
|
|
13
|
-
const LifeUpdater_js_1 = require("./LifeUpdater.js");
|
|
14
37
|
async function loadLifeUpdater(engine, refresh = true) {
|
|
15
|
-
await engine.addParticleUpdater("life", (container) =>
|
|
38
|
+
await engine.addParticleUpdater("life", async (container) => {
|
|
39
|
+
const { LifeUpdater } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./LifeUpdater.js"))) : new Promise((resolve_1, reject_1) => { require(["./LifeUpdater.js"], resolve_1, reject_1); }).then(__importStar));
|
|
40
|
+
return new LifeUpdater(container);
|
|
41
|
+
}, refresh);
|
|
16
42
|
}
|
|
17
43
|
exports.loadLifeUpdater = loadLifeUpdater;
|
|
18
44
|
});
|