@tsparticles/updater-life 3.0.3 → 3.2.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/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 +20 -65
- package/browser/Utils.js +56 -0
- package/browser/index.js +4 -2
- package/cjs/LifeUpdater.js +42 -64
- 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 +20 -65
- 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 -175
- 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 +43 -64
- package/umd/Utils.js +70 -0
- package/umd/index.js +29 -3
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
|
});
|