@tsparticles/updater-out-modes 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/388.min.js +2 -0
- package/388.min.js.LICENSE.txt +1 -0
- package/53.min.js +2 -0
- package/53.min.js.LICENSE.txt +1 -0
- package/569.min.js +2 -0
- package/569.min.js.LICENSE.txt +1 -0
- package/886.min.js +2 -0
- package/886.min.js.LICENSE.txt +1 -0
- package/920.min.js +2 -0
- package/920.min.js.LICENSE.txt +1 -0
- package/browser/BounceOutMode.js +3 -8
- package/browser/DestroyOutMode.js +8 -7
- package/browser/NoneOutMode.js +9 -9
- package/browser/OutOfCanvasUpdater.js +35 -19
- package/browser/OutOutMode.js +7 -2
- package/browser/Utils.js +15 -16
- package/browser/index.js +4 -2
- package/cjs/BounceOutMode.js +28 -10
- package/cjs/DestroyOutMode.js +8 -7
- package/cjs/NoneOutMode.js +9 -9
- package/cjs/OutOfCanvasUpdater.js +58 -19
- package/cjs/OutOutMode.js +7 -2
- package/cjs/Utils.js +15 -16
- package/cjs/index.js +27 -2
- package/dist_browser_BounceOutMode_js.js +30 -0
- package/dist_browser_DestroyOutMode_js.js +30 -0
- package/dist_browser_NoneOutMode_js.js +30 -0
- package/dist_browser_OutOfCanvasUpdater_js.js +30 -0
- package/dist_browser_OutOutMode_js.js +30 -0
- package/dist_browser_Utils_js.js +30 -0
- package/esm/BounceOutMode.js +3 -8
- package/esm/DestroyOutMode.js +8 -7
- package/esm/NoneOutMode.js +9 -9
- package/esm/OutOfCanvasUpdater.js +35 -19
- package/esm/OutOutMode.js +7 -2
- package/esm/Utils.js +15 -16
- package/esm/index.js +4 -2
- package/package.json +2 -2
- package/report.html +3 -3
- package/tsparticles.updater.out-modes.js +241 -354
- package/tsparticles.updater.out-modes.min.js +1 -1
- package/tsparticles.updater.out-modes.min.js.LICENSE.txt +1 -1
- package/types/BounceOutMode.d.ts +3 -3
- package/types/DestroyOutMode.d.ts +3 -3
- package/types/IBounceData.d.ts +2 -2
- package/types/IOutModeManager.d.ts +3 -3
- package/types/NoneOutMode.d.ts +3 -3
- package/types/OutOfCanvasUpdater.d.ts +3 -3
- package/types/OutOutMode.d.ts +3 -3
- package/umd/BounceOutMode.js +30 -11
- package/umd/DestroyOutMode.js +8 -7
- package/umd/NoneOutMode.js +9 -9
- package/umd/OutOfCanvasUpdater.js +60 -20
- package/umd/OutOutMode.js +7 -2
- package/umd/Utils.js +15 -16
- package/umd/index.js +29 -3
package/cjs/OutOutMode.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OutOutMode = void 0;
|
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
|
+
const minVelocity = 0, minDistance = 0;
|
|
5
6
|
class OutOutMode {
|
|
6
7
|
constructor(container) {
|
|
7
8
|
this.container = container;
|
|
8
9
|
this.modes = ["out"];
|
|
9
10
|
}
|
|
10
|
-
update(particle, direction, delta, outMode) {
|
|
11
|
+
async update(particle, direction, delta, outMode) {
|
|
11
12
|
if (!this.modes.includes(outMode)) {
|
|
12
13
|
return;
|
|
13
14
|
}
|
|
@@ -20,7 +21,10 @@ class OutOutMode {
|
|
|
20
21
|
circVec.angle = particle.velocity.angle + Math.PI;
|
|
21
22
|
circVec.addTo(engine_1.Vector.create(particle.moveCenter));
|
|
22
23
|
const { dx, dy } = (0, engine_1.getDistances)(particle.position, circVec);
|
|
23
|
-
if ((vx <=
|
|
24
|
+
if ((vx <= minVelocity && dx >= minDistance) ||
|
|
25
|
+
(vy <= minVelocity && dy >= minDistance) ||
|
|
26
|
+
(vx >= minVelocity && dx <= minDistance) ||
|
|
27
|
+
(vy >= minVelocity && dy <= minDistance)) {
|
|
24
28
|
return;
|
|
25
29
|
}
|
|
26
30
|
particle.position.x = Math.floor((0, engine_1.randomInRange)({
|
|
@@ -106,6 +110,7 @@ class OutOutMode {
|
|
|
106
110
|
break;
|
|
107
111
|
}
|
|
108
112
|
}
|
|
113
|
+
await Promise.resolve();
|
|
109
114
|
}
|
|
110
115
|
}
|
|
111
116
|
exports.OutOutMode = OutOutMode;
|
package/cjs/Utils.js
CHANGED
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.bounceVertical = exports.bounceHorizontal = void 0;
|
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
|
+
const minVelocity = 0, boundsMin = 0;
|
|
5
6
|
function bounceHorizontal(data) {
|
|
6
|
-
if ((data.outMode !== "bounce" &&
|
|
7
|
-
data.outMode !== "bounce-horizontal" &&
|
|
8
|
-
data.outMode !== "bounceHorizontal" &&
|
|
9
|
-
data.outMode !== "split") ||
|
|
7
|
+
if ((data.outMode !== "bounce" && data.outMode !== "split") ||
|
|
10
8
|
(data.direction !== "left" && data.direction !== "right")) {
|
|
11
9
|
return;
|
|
12
10
|
}
|
|
13
|
-
if (data.bounds.right <
|
|
11
|
+
if (data.bounds.right < boundsMin && data.direction === "left") {
|
|
14
12
|
data.particle.position.x = data.size + data.offset.x;
|
|
15
13
|
}
|
|
16
14
|
else if (data.bounds.left > data.canvasSize.width && data.direction === "right") {
|
|
@@ -18,8 +16,10 @@ function bounceHorizontal(data) {
|
|
|
18
16
|
}
|
|
19
17
|
const velocity = data.particle.velocity.x;
|
|
20
18
|
let bounced = false;
|
|
21
|
-
if ((data.direction === "right" &&
|
|
22
|
-
|
|
19
|
+
if ((data.direction === "right" &&
|
|
20
|
+
data.bounds.right >= data.canvasSize.width &&
|
|
21
|
+
velocity > minVelocity) ||
|
|
22
|
+
(data.direction === "left" && data.bounds.left <= boundsMin && velocity < minVelocity)) {
|
|
23
23
|
const newVelocity = (0, engine_1.getRangeValue)(data.particle.options.bounce.horizontal.value);
|
|
24
24
|
data.particle.velocity.x *= -newVelocity;
|
|
25
25
|
bounced = true;
|
|
@@ -31,7 +31,7 @@ function bounceHorizontal(data) {
|
|
|
31
31
|
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") {
|
|
32
32
|
data.particle.position.x = data.canvasSize.width - minPos;
|
|
33
33
|
}
|
|
34
|
-
else if (data.bounds.left <=
|
|
34
|
+
else if (data.bounds.left <= boundsMin && data.direction === "left") {
|
|
35
35
|
data.particle.position.x = minPos;
|
|
36
36
|
}
|
|
37
37
|
if (data.outMode === "split") {
|
|
@@ -40,14 +40,11 @@ function bounceHorizontal(data) {
|
|
|
40
40
|
}
|
|
41
41
|
exports.bounceHorizontal = bounceHorizontal;
|
|
42
42
|
function bounceVertical(data) {
|
|
43
|
-
if ((data.outMode !== "bounce" &&
|
|
44
|
-
data.outMode !== "bounce-vertical" &&
|
|
45
|
-
data.outMode !== "bounceVertical" &&
|
|
46
|
-
data.outMode !== "split") ||
|
|
43
|
+
if ((data.outMode !== "bounce" && data.outMode !== "split") ||
|
|
47
44
|
(data.direction !== "bottom" && data.direction !== "top")) {
|
|
48
45
|
return;
|
|
49
46
|
}
|
|
50
|
-
if (data.bounds.bottom <
|
|
47
|
+
if (data.bounds.bottom < boundsMin && data.direction === "top") {
|
|
51
48
|
data.particle.position.y = data.size + data.offset.y;
|
|
52
49
|
}
|
|
53
50
|
else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") {
|
|
@@ -55,8 +52,10 @@ function bounceVertical(data) {
|
|
|
55
52
|
}
|
|
56
53
|
const velocity = data.particle.velocity.y;
|
|
57
54
|
let bounced = false;
|
|
58
|
-
if ((data.direction === "bottom" &&
|
|
59
|
-
|
|
55
|
+
if ((data.direction === "bottom" &&
|
|
56
|
+
data.bounds.bottom >= data.canvasSize.height &&
|
|
57
|
+
velocity > minVelocity) ||
|
|
58
|
+
(data.direction === "top" && data.bounds.top <= boundsMin && velocity < minVelocity)) {
|
|
60
59
|
const newVelocity = (0, engine_1.getRangeValue)(data.particle.options.bounce.vertical.value);
|
|
61
60
|
data.particle.velocity.y *= -newVelocity;
|
|
62
61
|
bounced = true;
|
|
@@ -68,7 +67,7 @@ function bounceVertical(data) {
|
|
|
68
67
|
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") {
|
|
69
68
|
data.particle.position.y = data.canvasSize.height - minPos;
|
|
70
69
|
}
|
|
71
|
-
else if (data.bounds.top <=
|
|
70
|
+
else if (data.bounds.top <= boundsMin && data.direction === "top") {
|
|
72
71
|
data.particle.position.y = minPos;
|
|
73
72
|
}
|
|
74
73
|
if (data.outMode === "split") {
|
package/cjs/index.js
CHANGED
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.loadOutModesUpdater = void 0;
|
|
4
|
-
const OutOfCanvasUpdater_js_1 = require("./OutOfCanvasUpdater.js");
|
|
5
27
|
async function loadOutModesUpdater(engine, refresh = true) {
|
|
6
|
-
await engine.addParticleUpdater("outModes", (container) =>
|
|
28
|
+
await engine.addParticleUpdater("outModes", async (container) => {
|
|
29
|
+
const { OutOfCanvasUpdater } = await Promise.resolve().then(() => __importStar(require("./OutOfCanvasUpdater.js")));
|
|
30
|
+
return new OutOfCanvasUpdater(container);
|
|
31
|
+
}, refresh);
|
|
7
32
|
}
|
|
8
33
|
exports.loadOutModesUpdater = loadOutModesUpdater;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v3.2.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_updater_out_modes"] = this["webpackChunk_tsparticles_updater_out_modes"] || []).push([["dist_browser_BounceOutMode_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/BounceOutMode.js":
|
|
21
|
+
/*!***************************************!*\
|
|
22
|
+
!*** ./dist/browser/BounceOutMode.js ***!
|
|
23
|
+
\***************************************/
|
|
24
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
25
|
+
|
|
26
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BounceOutMode: () => (/* binding */ BounceOutMode)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nclass BounceOutMode {\n constructor(container) {\n this.container = container;\n this.modes = [\"bounce\", \"split\"];\n }\n async update(particle, direction, delta, outMode) {\n if (!this.modes.includes(outMode)) {\n return;\n }\n const container = this.container;\n let handled = false;\n for (const [, plugin] of container.plugins) {\n if (plugin.particleBounce !== undefined) {\n handled = await plugin.particleBounce(particle, delta, direction);\n }\n if (handled) {\n break;\n }\n }\n if (handled) {\n return;\n }\n const pos = particle.getPosition(),\n offset = particle.offset,\n size = particle.getRadius(),\n bounds = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.calculateBounds)(pos, size),\n canvasSize = container.canvas.size,\n {\n bounceHorizontal,\n bounceVertical\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_Utils_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./Utils.js */ \"./dist/browser/Utils.js\"));\n bounceHorizontal({\n particle,\n outMode,\n direction,\n bounds,\n canvasSize,\n offset,\n size\n });\n bounceVertical({\n particle,\n outMode,\n direction,\n bounds,\n canvasSize,\n offset,\n size\n });\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/BounceOutMode.js?");
|
|
27
|
+
|
|
28
|
+
/***/ })
|
|
29
|
+
|
|
30
|
+
}]);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v3.2.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_updater_out_modes"] = this["webpackChunk_tsparticles_updater_out_modes"] || []).push([["dist_browser_DestroyOutMode_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/DestroyOutMode.js":
|
|
21
|
+
/*!****************************************!*\
|
|
22
|
+
!*** ./dist/browser/DestroyOutMode.js ***!
|
|
23
|
+
\****************************************/
|
|
24
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
25
|
+
|
|
26
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DestroyOutMode: () => (/* binding */ DestroyOutMode)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst minVelocity = 0;\nclass DestroyOutMode {\n constructor(container) {\n this.container = container;\n this.modes = [\"destroy\"];\n }\n async update(particle, direction, _delta, outMode) {\n if (!this.modes.includes(outMode)) {\n return;\n }\n const container = this.container;\n switch (particle.outType) {\n case \"normal\":\n case \"outside\":\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isPointInside)(particle.position, container.canvas.size, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin, particle.getRadius(), direction)) {\n return;\n }\n break;\n case \"inside\":\n {\n const {\n dx,\n dy\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(particle.position, particle.moveCenter),\n {\n x: vx,\n y: vy\n } = particle.velocity;\n if (vx < minVelocity && dx > particle.moveCenter.radius || vy < minVelocity && dy > particle.moveCenter.radius || vx >= minVelocity && dx < -particle.moveCenter.radius || vy >= minVelocity && dy < -particle.moveCenter.radius) {\n return;\n }\n break;\n }\n }\n container.particles.remove(particle, undefined, true);\n await Promise.resolve();\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/DestroyOutMode.js?");
|
|
27
|
+
|
|
28
|
+
/***/ })
|
|
29
|
+
|
|
30
|
+
}]);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v3.2.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_updater_out_modes"] = this["webpackChunk_tsparticles_updater_out_modes"] || []).push([["dist_browser_NoneOutMode_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/NoneOutMode.js":
|
|
21
|
+
/*!*************************************!*\
|
|
22
|
+
!*** ./dist/browser/NoneOutMode.js ***!
|
|
23
|
+
\*************************************/
|
|
24
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
25
|
+
|
|
26
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ NoneOutMode: () => (/* binding */ NoneOutMode)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst minVelocity = 0;\nclass NoneOutMode {\n constructor(container) {\n this.container = container;\n this.modes = [\"none\"];\n }\n async update(particle, direction, delta, outMode) {\n if (!this.modes.includes(outMode)) {\n return;\n }\n if ((particle.options.move.distance.horizontal && (direction === \"left\" || direction === \"right\")) ?? (particle.options.move.distance.vertical && (direction === \"top\" || direction === \"bottom\"))) {\n return;\n }\n const gravityOptions = particle.options.move.gravity,\n container = this.container,\n canvasSize = container.canvas.size,\n pRadius = particle.getRadius();\n if (!gravityOptions.enable) {\n if (particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius || particle.velocity.y < minVelocity && particle.position.y >= -pRadius || particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius || particle.velocity.x < minVelocity && particle.position.x >= -pRadius) {\n return;\n }\n if (!(0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isPointInside)(particle.position, container.canvas.size, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin, pRadius, direction)) {\n container.particles.remove(particle);\n }\n } else {\n const position = particle.position;\n if (!gravityOptions.inverse && position.y > canvasSize.height + pRadius && direction === \"bottom\" || gravityOptions.inverse && position.y < -pRadius && direction === \"top\") {\n container.particles.remove(particle);\n }\n }\n await Promise.resolve();\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/NoneOutMode.js?");
|
|
27
|
+
|
|
28
|
+
/***/ })
|
|
29
|
+
|
|
30
|
+
}]);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v3.2.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_updater_out_modes"] = this["webpackChunk_tsparticles_updater_out_modes"] || []).push([["dist_browser_OutOfCanvasUpdater_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/OutOfCanvasUpdater.js":
|
|
21
|
+
/*!********************************************!*\
|
|
22
|
+
!*** ./dist/browser/OutOfCanvasUpdater.js ***!
|
|
23
|
+
\********************************************/
|
|
24
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
25
|
+
|
|
26
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ OutOfCanvasUpdater: () => (/* binding */ OutOfCanvasUpdater)\n/* harmony export */ });\nconst checkOutMode = (outModes, outMode) => {\n return outModes.default === outMode || outModes.bottom === outMode || outModes.left === outMode || outModes.right === outMode || outModes.top === outMode;\n};\nclass OutOfCanvasUpdater {\n constructor(container) {\n this._updateOutMode = async (particle, delta, outMode, direction) => {\n for (const updater of this.updaters) {\n await updater.update(particle, direction, delta, outMode);\n }\n };\n this.container = container;\n this.updaters = [];\n }\n async init(particle) {\n this.updaters = [];\n const outModes = particle.options.move.outModes;\n if (checkOutMode(outModes, \"bounce\")) {\n const {\n BounceOutMode\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_BounceOutMode_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./BounceOutMode.js */ \"./dist/browser/BounceOutMode.js\"));\n this.updaters.push(new BounceOutMode(this.container));\n } else if (checkOutMode(outModes, \"out\")) {\n const {\n OutOutMode\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_OutOutMode_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./OutOutMode.js */ \"./dist/browser/OutOutMode.js\"));\n this.updaters.push(new OutOutMode(this.container));\n } else if (checkOutMode(outModes, \"destroy\")) {\n const {\n DestroyOutMode\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_DestroyOutMode_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./DestroyOutMode.js */ \"./dist/browser/DestroyOutMode.js\"));\n this.updaters.push(new DestroyOutMode(this.container));\n } else if (checkOutMode(outModes, \"none\")) {\n const {\n NoneOutMode\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_NoneOutMode_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./NoneOutMode.js */ \"./dist/browser/NoneOutMode.js\"));\n this.updaters.push(new NoneOutMode(this.container));\n }\n }\n isEnabled(particle) {\n return !particle.destroyed && !particle.spawning;\n }\n async update(particle, delta) {\n const outModes = particle.options.move.outModes;\n await this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, \"bottom\");\n await this._updateOutMode(particle, delta, outModes.left ?? outModes.default, \"left\");\n await this._updateOutMode(particle, delta, outModes.right ?? outModes.default, \"right\");\n await this._updateOutMode(particle, delta, outModes.top ?? outModes.default, \"top\");\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/OutOfCanvasUpdater.js?");
|
|
27
|
+
|
|
28
|
+
/***/ })
|
|
29
|
+
|
|
30
|
+
}]);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v3.2.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_updater_out_modes"] = this["webpackChunk_tsparticles_updater_out_modes"] || []).push([["dist_browser_OutOutMode_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/OutOutMode.js":
|
|
21
|
+
/*!************************************!*\
|
|
22
|
+
!*** ./dist/browser/OutOutMode.js ***!
|
|
23
|
+
\************************************/
|
|
24
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
25
|
+
|
|
26
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ OutOutMode: () => (/* binding */ OutOutMode)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst minVelocity = 0,\n minDistance = 0;\nclass OutOutMode {\n constructor(container) {\n this.container = container;\n this.modes = [\"out\"];\n }\n async update(particle, direction, delta, outMode) {\n if (!this.modes.includes(outMode)) {\n return;\n }\n const container = this.container;\n switch (particle.outType) {\n case \"inside\":\n {\n const {\n x: vx,\n y: vy\n } = particle.velocity;\n const circVec = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n circVec.length = particle.moveCenter.radius;\n circVec.angle = particle.velocity.angle + Math.PI;\n circVec.addTo(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.create(particle.moveCenter));\n const {\n dx,\n dy\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(particle.position, circVec);\n if (vx <= minVelocity && dx >= minDistance || vy <= minVelocity && dy >= minDistance || vx >= minVelocity && dx <= minDistance || vy >= minVelocity && dy <= minDistance) {\n return;\n }\n particle.position.x = Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRange)({\n min: 0,\n max: container.canvas.size.width\n }));\n particle.position.y = Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRange)({\n min: 0,\n max: container.canvas.size.height\n }));\n const {\n dx: newDx,\n dy: newDy\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(particle.position, particle.moveCenter);\n particle.direction = Math.atan2(-newDy, -newDx);\n particle.velocity.angle = particle.direction;\n break;\n }\n default:\n {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isPointInside)(particle.position, container.canvas.size, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin, particle.getRadius(), direction)) {\n return;\n }\n switch (particle.outType) {\n case \"outside\":\n {\n particle.position.x = Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRange)({\n min: -particle.moveCenter.radius,\n max: particle.moveCenter.radius\n })) + particle.moveCenter.x;\n particle.position.y = Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRange)({\n min: -particle.moveCenter.radius,\n max: particle.moveCenter.radius\n })) + particle.moveCenter.y;\n const {\n dx,\n dy\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(particle.position, particle.moveCenter);\n if (particle.moveCenter.radius) {\n particle.direction = Math.atan2(dy, dx);\n particle.velocity.angle = particle.direction;\n }\n break;\n }\n case \"normal\":\n {\n const warp = particle.options.move.warp,\n canvasSize = container.canvas.size,\n newPos = {\n bottom: canvasSize.height + particle.getRadius() + particle.offset.y,\n left: -particle.getRadius() - particle.offset.x,\n right: canvasSize.width + particle.getRadius() + particle.offset.x,\n top: -particle.getRadius() - particle.offset.y\n },\n sizeValue = particle.getRadius(),\n nextBounds = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.calculateBounds)(particle.position, sizeValue);\n if (direction === \"right\" && nextBounds.left > canvasSize.width + particle.offset.x) {\n particle.position.x = newPos.left;\n particle.initialPosition.x = particle.position.x;\n if (!warp) {\n particle.position.y = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * canvasSize.height;\n particle.initialPosition.y = particle.position.y;\n }\n } else if (direction === \"left\" && nextBounds.right < -particle.offset.x) {\n particle.position.x = newPos.right;\n particle.initialPosition.x = particle.position.x;\n if (!warp) {\n particle.position.y = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * canvasSize.height;\n particle.initialPosition.y = particle.position.y;\n }\n }\n if (direction === \"bottom\" && nextBounds.top > canvasSize.height + particle.offset.y) {\n if (!warp) {\n particle.position.x = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * canvasSize.width;\n particle.initialPosition.x = particle.position.x;\n }\n particle.position.y = newPos.top;\n particle.initialPosition.y = particle.position.y;\n } else if (direction === \"top\" && nextBounds.bottom < -particle.offset.y) {\n if (!warp) {\n particle.position.x = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * canvasSize.width;\n particle.initialPosition.x = particle.position.x;\n }\n particle.position.y = newPos.bottom;\n particle.initialPosition.y = particle.position.y;\n }\n break;\n }\n }\n break;\n }\n }\n await Promise.resolve();\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/OutOutMode.js?");
|
|
27
|
+
|
|
28
|
+
/***/ })
|
|
29
|
+
|
|
30
|
+
}]);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v3.2.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_updater_out_modes"] = this["webpackChunk_tsparticles_updater_out_modes"] || []).push([["dist_browser_Utils_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/Utils.js":
|
|
21
|
+
/*!*******************************!*\
|
|
22
|
+
!*** ./dist/browser/Utils.js ***!
|
|
23
|
+
\*******************************/
|
|
24
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
25
|
+
|
|
26
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ bounceHorizontal: () => (/* binding */ bounceHorizontal),\n/* harmony export */ bounceVertical: () => (/* binding */ bounceVertical)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst minVelocity = 0,\n boundsMin = 0;\nfunction bounceHorizontal(data) {\n if (data.outMode !== \"bounce\" && data.outMode !== \"split\" || data.direction !== \"left\" && data.direction !== \"right\") {\n return;\n }\n if (data.bounds.right < boundsMin && data.direction === \"left\") {\n data.particle.position.x = data.size + data.offset.x;\n } else if (data.bounds.left > data.canvasSize.width && data.direction === \"right\") {\n data.particle.position.x = data.canvasSize.width - data.size - data.offset.x;\n }\n const velocity = data.particle.velocity.x;\n let bounced = false;\n if (data.direction === \"right\" && data.bounds.right >= data.canvasSize.width && velocity > minVelocity || data.direction === \"left\" && data.bounds.left <= boundsMin && velocity < minVelocity) {\n const newVelocity = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(data.particle.options.bounce.horizontal.value);\n data.particle.velocity.x *= -newVelocity;\n bounced = true;\n }\n if (!bounced) {\n return;\n }\n const minPos = data.offset.x + data.size;\n if (data.bounds.right >= data.canvasSize.width && data.direction === \"right\") {\n data.particle.position.x = data.canvasSize.width - minPos;\n } else if (data.bounds.left <= boundsMin && data.direction === \"left\") {\n data.particle.position.x = minPos;\n }\n if (data.outMode === \"split\") {\n data.particle.destroy();\n }\n}\nfunction bounceVertical(data) {\n if (data.outMode !== \"bounce\" && data.outMode !== \"split\" || data.direction !== \"bottom\" && data.direction !== \"top\") {\n return;\n }\n if (data.bounds.bottom < boundsMin && data.direction === \"top\") {\n data.particle.position.y = data.size + data.offset.y;\n } else if (data.bounds.top > data.canvasSize.height && data.direction === \"bottom\") {\n data.particle.position.y = data.canvasSize.height - data.size - data.offset.y;\n }\n const velocity = data.particle.velocity.y;\n let bounced = false;\n if (data.direction === \"bottom\" && data.bounds.bottom >= data.canvasSize.height && velocity > minVelocity || data.direction === \"top\" && data.bounds.top <= boundsMin && velocity < minVelocity) {\n const newVelocity = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(data.particle.options.bounce.vertical.value);\n data.particle.velocity.y *= -newVelocity;\n bounced = true;\n }\n if (!bounced) {\n return;\n }\n const minPos = data.offset.y + data.size;\n if (data.bounds.bottom >= data.canvasSize.height && data.direction === \"bottom\") {\n data.particle.position.y = data.canvasSize.height - minPos;\n } else if (data.bounds.top <= boundsMin && data.direction === \"top\") {\n data.particle.position.y = minPos;\n }\n if (data.outMode === \"split\") {\n data.particle.destroy();\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-out-modes/./dist/browser/Utils.js?");
|
|
27
|
+
|
|
28
|
+
/***/ })
|
|
29
|
+
|
|
30
|
+
}]);
|
package/esm/BounceOutMode.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { calculateBounds, } from "@tsparticles/engine";
|
|
2
|
-
import { bounceHorizontal, bounceVertical } from "./Utils.js";
|
|
3
2
|
export class BounceOutMode {
|
|
4
3
|
constructor(container) {
|
|
5
4
|
this.container = container;
|
|
6
5
|
this.modes = [
|
|
7
6
|
"bounce",
|
|
8
|
-
"bounce-vertical",
|
|
9
|
-
"bounce-horizontal",
|
|
10
|
-
"bounceVertical",
|
|
11
|
-
"bounceHorizontal",
|
|
12
7
|
"split",
|
|
13
8
|
];
|
|
14
9
|
}
|
|
15
|
-
update(particle, direction, delta, outMode) {
|
|
10
|
+
async update(particle, direction, delta, outMode) {
|
|
16
11
|
if (!this.modes.includes(outMode)) {
|
|
17
12
|
return;
|
|
18
13
|
}
|
|
@@ -20,7 +15,7 @@ export class BounceOutMode {
|
|
|
20
15
|
let handled = false;
|
|
21
16
|
for (const [, plugin] of container.plugins) {
|
|
22
17
|
if (plugin.particleBounce !== undefined) {
|
|
23
|
-
handled = plugin.particleBounce(particle, delta, direction);
|
|
18
|
+
handled = await plugin.particleBounce(particle, delta, direction);
|
|
24
19
|
}
|
|
25
20
|
if (handled) {
|
|
26
21
|
break;
|
|
@@ -29,7 +24,7 @@ export class BounceOutMode {
|
|
|
29
24
|
if (handled) {
|
|
30
25
|
return;
|
|
31
26
|
}
|
|
32
|
-
const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size;
|
|
27
|
+
const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = calculateBounds(pos, size), canvasSize = container.canvas.size, { bounceHorizontal, bounceVertical } = await import("./Utils.js");
|
|
33
28
|
bounceHorizontal({ particle, outMode, direction, bounds, canvasSize, offset, size });
|
|
34
29
|
bounceVertical({ particle, outMode, direction, bounds, canvasSize, offset, size });
|
|
35
30
|
}
|
package/esm/DestroyOutMode.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Vector, getDistances, isPointInside, } from "@tsparticles/engine";
|
|
2
|
+
const minVelocity = 0;
|
|
2
3
|
export class DestroyOutMode {
|
|
3
4
|
constructor(container) {
|
|
4
5
|
this.container = container;
|
|
5
6
|
this.modes = ["destroy"];
|
|
6
7
|
}
|
|
7
|
-
update(particle, direction, _delta, outMode) {
|
|
8
|
+
async update(particle, direction, _delta, outMode) {
|
|
8
9
|
if (!this.modes.includes(outMode)) {
|
|
9
10
|
return;
|
|
10
11
|
}
|
|
@@ -17,17 +18,17 @@ export class DestroyOutMode {
|
|
|
17
18
|
}
|
|
18
19
|
break;
|
|
19
20
|
case "inside": {
|
|
20
|
-
const { dx, dy } = getDistances(particle.position, particle.moveCenter);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
(
|
|
24
|
-
(
|
|
25
|
-
(vy >= 0 && dy < -particle.moveCenter.radius)) {
|
|
21
|
+
const { dx, dy } = getDistances(particle.position, particle.moveCenter), { x: vx, y: vy } = particle.velocity;
|
|
22
|
+
if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
|
|
23
|
+
(vy < minVelocity && dy > particle.moveCenter.radius) ||
|
|
24
|
+
(vx >= minVelocity && dx < -particle.moveCenter.radius) ||
|
|
25
|
+
(vy >= minVelocity && dy < -particle.moveCenter.radius)) {
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
break;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
container.particles.remove(particle, undefined, true);
|
|
32
|
+
await Promise.resolve();
|
|
32
33
|
}
|
|
33
34
|
}
|
package/esm/NoneOutMode.js
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import { Vector, isPointInside, } from "@tsparticles/engine";
|
|
2
|
+
const minVelocity = 0;
|
|
2
3
|
export class NoneOutMode {
|
|
3
4
|
constructor(container) {
|
|
4
5
|
this.container = container;
|
|
5
6
|
this.modes = ["none"];
|
|
6
7
|
}
|
|
7
|
-
update(particle, direction, delta, outMode) {
|
|
8
|
+
async update(particle, direction, delta, outMode) {
|
|
8
9
|
if (!this.modes.includes(outMode)) {
|
|
9
10
|
return;
|
|
10
11
|
}
|
|
11
12
|
if ((particle.options.move.distance.horizontal &&
|
|
12
|
-
(direction === "left" || direction === "right"))
|
|
13
|
+
(direction === "left" || direction === "right")) ??
|
|
13
14
|
(particle.options.move.distance.vertical &&
|
|
14
15
|
(direction === "top" || direction === "bottom"))) {
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
17
|
-
const gravityOptions = particle.options.move.gravity, container = this.container;
|
|
18
|
-
const canvasSize = container.canvas.size;
|
|
19
|
-
const pRadius = particle.getRadius();
|
|
18
|
+
const gravityOptions = particle.options.move.gravity, container = this.container, canvasSize = container.canvas.size, pRadius = particle.getRadius();
|
|
20
19
|
if (!gravityOptions.enable) {
|
|
21
|
-
if ((particle.velocity.y >
|
|
22
|
-
(particle.velocity.y <
|
|
23
|
-
(particle.velocity.x >
|
|
24
|
-
(particle.velocity.x <
|
|
20
|
+
if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) ||
|
|
21
|
+
(particle.velocity.y < minVelocity && particle.position.y >= -pRadius) ||
|
|
22
|
+
(particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius) ||
|
|
23
|
+
(particle.velocity.x < minVelocity && particle.position.x >= -pRadius)) {
|
|
25
24
|
return;
|
|
26
25
|
}
|
|
27
26
|
if (!isPointInside(particle.position, container.canvas.size, Vector.origin, pRadius, direction)) {
|
|
@@ -37,5 +36,6 @@ export class NoneOutMode {
|
|
|
37
36
|
container.particles.remove(particle);
|
|
38
37
|
}
|
|
39
38
|
}
|
|
39
|
+
await Promise.resolve();
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -1,32 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const checkOutMode = (outModes, outMode) => {
|
|
2
|
+
return (outModes.default === outMode ||
|
|
3
|
+
outModes.bottom === outMode ||
|
|
4
|
+
outModes.left === outMode ||
|
|
5
|
+
outModes.right === outMode ||
|
|
6
|
+
outModes.top === outMode);
|
|
7
|
+
};
|
|
5
8
|
export class OutOfCanvasUpdater {
|
|
6
9
|
constructor(container) {
|
|
7
|
-
this.
|
|
8
|
-
this._updateOutMode = (particle, delta, outMode, direction) => {
|
|
10
|
+
this._updateOutMode = async (particle, delta, outMode, direction) => {
|
|
9
11
|
for (const updater of this.updaters) {
|
|
10
|
-
updater.update(particle, direction, delta, outMode);
|
|
12
|
+
await updater.update(particle, direction, delta, outMode);
|
|
11
13
|
}
|
|
12
14
|
};
|
|
13
|
-
this.
|
|
14
|
-
|
|
15
|
-
new DestroyOutMode(container),
|
|
16
|
-
new OutOutMode(container),
|
|
17
|
-
new NoneOutMode(container),
|
|
18
|
-
];
|
|
15
|
+
this.container = container;
|
|
16
|
+
this.updaters = [];
|
|
19
17
|
}
|
|
20
|
-
init() {
|
|
18
|
+
async init(particle) {
|
|
19
|
+
this.updaters = [];
|
|
20
|
+
const outModes = particle.options.move.outModes;
|
|
21
|
+
if (checkOutMode(outModes, "bounce")) {
|
|
22
|
+
const { BounceOutMode } = await import("./BounceOutMode.js");
|
|
23
|
+
this.updaters.push(new BounceOutMode(this.container));
|
|
24
|
+
}
|
|
25
|
+
else if (checkOutMode(outModes, "out")) {
|
|
26
|
+
const { OutOutMode } = await import("./OutOutMode.js");
|
|
27
|
+
this.updaters.push(new OutOutMode(this.container));
|
|
28
|
+
}
|
|
29
|
+
else if (checkOutMode(outModes, "destroy")) {
|
|
30
|
+
const { DestroyOutMode } = await import("./DestroyOutMode.js");
|
|
31
|
+
this.updaters.push(new DestroyOutMode(this.container));
|
|
32
|
+
}
|
|
33
|
+
else if (checkOutMode(outModes, "none")) {
|
|
34
|
+
const { NoneOutMode } = await import("./NoneOutMode.js");
|
|
35
|
+
this.updaters.push(new NoneOutMode(this.container));
|
|
36
|
+
}
|
|
21
37
|
}
|
|
22
38
|
isEnabled(particle) {
|
|
23
39
|
return !particle.destroyed && !particle.spawning;
|
|
24
40
|
}
|
|
25
|
-
update(particle, delta) {
|
|
41
|
+
async update(particle, delta) {
|
|
26
42
|
const outModes = particle.options.move.outModes;
|
|
27
|
-
this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom");
|
|
28
|
-
this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left");
|
|
29
|
-
this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right");
|
|
30
|
-
this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top");
|
|
43
|
+
await this._updateOutMode(particle, delta, outModes.bottom ?? outModes.default, "bottom");
|
|
44
|
+
await this._updateOutMode(particle, delta, outModes.left ?? outModes.default, "left");
|
|
45
|
+
await this._updateOutMode(particle, delta, outModes.right ?? outModes.default, "right");
|
|
46
|
+
await this._updateOutMode(particle, delta, outModes.top ?? outModes.default, "top");
|
|
31
47
|
}
|
|
32
48
|
}
|
package/esm/OutOutMode.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Vector, calculateBounds, getDistances, getRandom, isPointInside, randomInRange, } from "@tsparticles/engine";
|
|
2
|
+
const minVelocity = 0, minDistance = 0;
|
|
2
3
|
export class OutOutMode {
|
|
3
4
|
constructor(container) {
|
|
4
5
|
this.container = container;
|
|
5
6
|
this.modes = ["out"];
|
|
6
7
|
}
|
|
7
|
-
update(particle, direction, delta, outMode) {
|
|
8
|
+
async update(particle, direction, delta, outMode) {
|
|
8
9
|
if (!this.modes.includes(outMode)) {
|
|
9
10
|
return;
|
|
10
11
|
}
|
|
@@ -17,7 +18,10 @@ export class OutOutMode {
|
|
|
17
18
|
circVec.angle = particle.velocity.angle + Math.PI;
|
|
18
19
|
circVec.addTo(Vector.create(particle.moveCenter));
|
|
19
20
|
const { dx, dy } = getDistances(particle.position, circVec);
|
|
20
|
-
if ((vx <=
|
|
21
|
+
if ((vx <= minVelocity && dx >= minDistance) ||
|
|
22
|
+
(vy <= minVelocity && dy >= minDistance) ||
|
|
23
|
+
(vx >= minVelocity && dx <= minDistance) ||
|
|
24
|
+
(vy >= minVelocity && dy <= minDistance)) {
|
|
21
25
|
return;
|
|
22
26
|
}
|
|
23
27
|
particle.position.x = Math.floor(randomInRange({
|
|
@@ -103,5 +107,6 @@ export class OutOutMode {
|
|
|
103
107
|
break;
|
|
104
108
|
}
|
|
105
109
|
}
|
|
110
|
+
await Promise.resolve();
|
|
106
111
|
}
|
|
107
112
|
}
|