@tsparticles/updater-out-modes 3.0.0-alpha.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/LICENSE +21 -0
- package/README.md +70 -0
- package/browser/BounceOutMode.js +36 -0
- package/browser/DestroyOutMode.js +33 -0
- package/browser/IBounceData.js +1 -0
- package/browser/IOutModeManager.js +1 -0
- package/browser/NoneOutMode.js +41 -0
- package/browser/OutOfCanvasUpdater.js +33 -0
- package/browser/OutOutMode.js +107 -0
- package/browser/Utils.js +71 -0
- package/browser/index.js +4 -0
- package/cjs/BounceOutMode.js +40 -0
- package/cjs/DestroyOutMode.js +37 -0
- package/cjs/IBounceData.js +2 -0
- package/cjs/IOutModeManager.js +2 -0
- package/cjs/NoneOutMode.js +45 -0
- package/cjs/OutOfCanvasUpdater.js +37 -0
- package/cjs/OutOutMode.js +111 -0
- package/cjs/Utils.js +76 -0
- package/cjs/index.js +19 -0
- package/esm/BounceOutMode.js +36 -0
- package/esm/DestroyOutMode.js +33 -0
- package/esm/IBounceData.js +1 -0
- package/esm/IOutModeManager.js +1 -0
- package/esm/NoneOutMode.js +41 -0
- package/esm/OutOfCanvasUpdater.js +33 -0
- package/esm/OutOutMode.js +107 -0
- package/esm/Utils.js +71 -0
- package/esm/index.js +4 -0
- package/package.json +82 -0
- package/report.html +39 -0
- package/tsparticles.updater.out-modes.js +440 -0
- package/tsparticles.updater.out-modes.min.js +2 -0
- package/tsparticles.updater.out-modes.min.js.LICENSE.txt +8 -0
- package/types/BounceOutMode.d.ts +9 -0
- package/types/DestroyOutMode.d.ts +9 -0
- package/types/IBounceData.d.ts +11 -0
- package/types/IOutModeManager.d.ts +5 -0
- package/types/NoneOutMode.d.ts +9 -0
- package/types/OutOfCanvasUpdater.d.ts +11 -0
- package/types/OutOutMode.d.ts +9 -0
- package/types/Utils.d.ts +3 -0
- package/types/index.d.ts +2 -0
- package/umd/BounceOutMode.js +50 -0
- package/umd/DestroyOutMode.js +47 -0
- package/umd/IBounceData.js +12 -0
- package/umd/IOutModeManager.js +12 -0
- package/umd/NoneOutMode.js +55 -0
- package/umd/OutOfCanvasUpdater.js +47 -0
- package/umd/OutOutMode.js +121 -0
- package/umd/Utils.js +86 -0
- package/umd/index.js +18 -0
|
@@ -0,0 +1,440 @@
|
|
|
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.0.0-alpha.0
|
|
8
|
+
*/
|
|
9
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
11
|
+
module.exports = factory(require("@tsparticles/engine"));
|
|
12
|
+
else if(typeof define === 'function' && define.amd)
|
|
13
|
+
define(["@tsparticles/engine"], factory);
|
|
14
|
+
else {
|
|
15
|
+
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
|
|
16
|
+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
17
|
+
}
|
|
18
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__533__) => {
|
|
19
|
+
return /******/ (() => { // webpackBootstrap
|
|
20
|
+
/******/ "use strict";
|
|
21
|
+
/******/ var __webpack_modules__ = ({
|
|
22
|
+
|
|
23
|
+
/***/ 533:
|
|
24
|
+
/***/ ((module) => {
|
|
25
|
+
|
|
26
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
|
|
27
|
+
|
|
28
|
+
/***/ })
|
|
29
|
+
|
|
30
|
+
/******/ });
|
|
31
|
+
/************************************************************************/
|
|
32
|
+
/******/ // The module cache
|
|
33
|
+
/******/ var __webpack_module_cache__ = {};
|
|
34
|
+
/******/
|
|
35
|
+
/******/ // The require function
|
|
36
|
+
/******/ function __webpack_require__(moduleId) {
|
|
37
|
+
/******/ // Check if module is in cache
|
|
38
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
39
|
+
/******/ if (cachedModule !== undefined) {
|
|
40
|
+
/******/ return cachedModule.exports;
|
|
41
|
+
/******/ }
|
|
42
|
+
/******/ // Create a new module (and put it into the cache)
|
|
43
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
44
|
+
/******/ // no module.id needed
|
|
45
|
+
/******/ // no module.loaded needed
|
|
46
|
+
/******/ exports: {}
|
|
47
|
+
/******/ };
|
|
48
|
+
/******/
|
|
49
|
+
/******/ // Execute the module function
|
|
50
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
51
|
+
/******/
|
|
52
|
+
/******/ // Return the exports of the module
|
|
53
|
+
/******/ return module.exports;
|
|
54
|
+
/******/ }
|
|
55
|
+
/******/
|
|
56
|
+
/************************************************************************/
|
|
57
|
+
/******/ /* webpack/runtime/define property getters */
|
|
58
|
+
/******/ (() => {
|
|
59
|
+
/******/ // define getter functions for harmony exports
|
|
60
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
61
|
+
/******/ for(var key in definition) {
|
|
62
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
63
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
64
|
+
/******/ }
|
|
65
|
+
/******/ }
|
|
66
|
+
/******/ };
|
|
67
|
+
/******/ })();
|
|
68
|
+
/******/
|
|
69
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
70
|
+
/******/ (() => {
|
|
71
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
72
|
+
/******/ })();
|
|
73
|
+
/******/
|
|
74
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
75
|
+
/******/ (() => {
|
|
76
|
+
/******/ // define __esModule on exports
|
|
77
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
78
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
79
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
80
|
+
/******/ }
|
|
81
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
82
|
+
/******/ };
|
|
83
|
+
/******/ })();
|
|
84
|
+
/******/
|
|
85
|
+
/************************************************************************/
|
|
86
|
+
var __webpack_exports__ = {};
|
|
87
|
+
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
88
|
+
(() => {
|
|
89
|
+
// ESM COMPAT FLAG
|
|
90
|
+
__webpack_require__.r(__webpack_exports__);
|
|
91
|
+
|
|
92
|
+
// EXPORTS
|
|
93
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
+
"loadOutModesUpdater": () => (/* binding */ loadOutModesUpdater)
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
98
|
+
var engine_root_window_ = __webpack_require__(533);
|
|
99
|
+
;// CONCATENATED MODULE: ./dist/browser/Utils.js
|
|
100
|
+
|
|
101
|
+
function bounceHorizontal(data) {
|
|
102
|
+
if (data.outMode !== "bounce" && data.outMode !== "bounce-horizontal" && data.outMode !== "bounceHorizontal" && data.outMode !== "split") {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (data.bounds.right < 0) {
|
|
106
|
+
data.particle.position.x = data.size + data.offset.x;
|
|
107
|
+
} else if (data.bounds.left > data.canvasSize.width) {
|
|
108
|
+
data.particle.position.x = data.canvasSize.width - data.size - data.offset.x;
|
|
109
|
+
}
|
|
110
|
+
const velocity = data.particle.velocity.x;
|
|
111
|
+
let bounced = false;
|
|
112
|
+
if (data.direction === "right" && data.bounds.right >= data.canvasSize.width && velocity > 0 || data.direction === "left" && data.bounds.left <= 0 && velocity < 0) {
|
|
113
|
+
const newVelocity = (0,engine_root_window_.getValue)(data.particle.options.bounce.horizontal);
|
|
114
|
+
data.particle.velocity.x *= -newVelocity;
|
|
115
|
+
bounced = true;
|
|
116
|
+
}
|
|
117
|
+
if (!bounced) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const minPos = data.offset.x + data.size;
|
|
121
|
+
if (data.bounds.right >= data.canvasSize.width) {
|
|
122
|
+
data.particle.position.x = data.canvasSize.width - minPos;
|
|
123
|
+
} else if (data.bounds.left <= 0) {
|
|
124
|
+
data.particle.position.x = minPos;
|
|
125
|
+
}
|
|
126
|
+
if (data.outMode === "split") {
|
|
127
|
+
data.particle.destroy();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function bounceVertical(data) {
|
|
131
|
+
if (data.outMode !== "bounce" && data.outMode !== "bounce-vertical" && data.outMode !== "bounceVertical" && data.outMode !== "split") {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (data.bounds.bottom < 0) {
|
|
135
|
+
data.particle.position.y = data.size + data.offset.y;
|
|
136
|
+
} else if (data.bounds.top > data.canvasSize.height) {
|
|
137
|
+
data.particle.position.y = data.canvasSize.height - data.size - data.offset.y;
|
|
138
|
+
}
|
|
139
|
+
const velocity = data.particle.velocity.y;
|
|
140
|
+
let bounced = false;
|
|
141
|
+
if (data.direction === "bottom" && data.bounds.bottom >= data.canvasSize.height && velocity > 0 || data.direction === "top" && data.bounds.top <= 0 && velocity < 0) {
|
|
142
|
+
const newVelocity = (0,engine_root_window_.getValue)(data.particle.options.bounce.vertical);
|
|
143
|
+
data.particle.velocity.y *= -newVelocity;
|
|
144
|
+
bounced = true;
|
|
145
|
+
}
|
|
146
|
+
if (!bounced) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const minPos = data.offset.y + data.size;
|
|
150
|
+
if (data.bounds.bottom >= data.canvasSize.height) {
|
|
151
|
+
data.particle.position.y = data.canvasSize.height - minPos;
|
|
152
|
+
} else if (data.bounds.top <= 0) {
|
|
153
|
+
data.particle.position.y = minPos;
|
|
154
|
+
}
|
|
155
|
+
if (data.outMode === "split") {
|
|
156
|
+
data.particle.destroy();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
;// CONCATENATED MODULE: ./dist/browser/BounceOutMode.js
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class BounceOutMode {
|
|
163
|
+
constructor(container) {
|
|
164
|
+
this.container = container;
|
|
165
|
+
this.modes = ["bounce", "bounce-vertical", "bounce-horizontal", "bounceVertical", "bounceHorizontal", "split"];
|
|
166
|
+
}
|
|
167
|
+
update(particle, direction, delta, outMode) {
|
|
168
|
+
if (!this.modes.includes(outMode)) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const container = this.container;
|
|
172
|
+
let handled = false;
|
|
173
|
+
for (const [, plugin] of container.plugins) {
|
|
174
|
+
if (plugin.particleBounce !== undefined) {
|
|
175
|
+
handled = plugin.particleBounce(particle, delta, direction);
|
|
176
|
+
}
|
|
177
|
+
if (handled) {
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (handled) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const pos = particle.getPosition(),
|
|
185
|
+
offset = particle.offset,
|
|
186
|
+
size = particle.getRadius(),
|
|
187
|
+
bounds = (0,engine_root_window_.calculateBounds)(pos, size),
|
|
188
|
+
canvasSize = container.canvas.size;
|
|
189
|
+
bounceHorizontal({
|
|
190
|
+
particle,
|
|
191
|
+
outMode,
|
|
192
|
+
direction,
|
|
193
|
+
bounds,
|
|
194
|
+
canvasSize,
|
|
195
|
+
offset,
|
|
196
|
+
size
|
|
197
|
+
});
|
|
198
|
+
bounceVertical({
|
|
199
|
+
particle,
|
|
200
|
+
outMode,
|
|
201
|
+
direction,
|
|
202
|
+
bounds,
|
|
203
|
+
canvasSize,
|
|
204
|
+
offset,
|
|
205
|
+
size
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
;// CONCATENATED MODULE: ./dist/browser/DestroyOutMode.js
|
|
210
|
+
|
|
211
|
+
class DestroyOutMode {
|
|
212
|
+
constructor(container) {
|
|
213
|
+
this.container = container;
|
|
214
|
+
this.modes = ["destroy"];
|
|
215
|
+
}
|
|
216
|
+
update(particle, direction, delta, outMode) {
|
|
217
|
+
if (!this.modes.includes(outMode)) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const container = this.container;
|
|
221
|
+
switch (particle.outType) {
|
|
222
|
+
case "normal":
|
|
223
|
+
case "outside":
|
|
224
|
+
if ((0,engine_root_window_.isPointInside)(particle.position, container.canvas.size, engine_root_window_.Vector.origin, particle.getRadius(), direction)) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
break;
|
|
228
|
+
case "inside":
|
|
229
|
+
{
|
|
230
|
+
const {
|
|
231
|
+
dx,
|
|
232
|
+
dy
|
|
233
|
+
} = (0,engine_root_window_.getDistances)(particle.position, particle.moveCenter);
|
|
234
|
+
const {
|
|
235
|
+
x: vx,
|
|
236
|
+
y: vy
|
|
237
|
+
} = particle.velocity;
|
|
238
|
+
if (vx < 0 && dx > particle.moveCenter.radius || vy < 0 && dy > particle.moveCenter.radius || vx >= 0 && dx < -particle.moveCenter.radius || vy >= 0 && dy < -particle.moveCenter.radius) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
container.particles.remove(particle, undefined, true);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
;// CONCATENATED MODULE: ./dist/browser/NoneOutMode.js
|
|
248
|
+
|
|
249
|
+
class NoneOutMode {
|
|
250
|
+
constructor(container) {
|
|
251
|
+
this.container = container;
|
|
252
|
+
this.modes = ["none"];
|
|
253
|
+
}
|
|
254
|
+
update(particle, direction, delta, outMode) {
|
|
255
|
+
if (!this.modes.includes(outMode)) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (particle.options.move.distance.horizontal && (direction === "left" || direction === "right") || particle.options.move.distance.vertical && (direction === "top" || direction === "bottom")) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
const gravityOptions = particle.options.move.gravity,
|
|
262
|
+
container = this.container;
|
|
263
|
+
const canvasSize = container.canvas.size;
|
|
264
|
+
const pRadius = particle.getRadius();
|
|
265
|
+
if (!gravityOptions.enable) {
|
|
266
|
+
if (particle.velocity.y > 0 && particle.position.y <= canvasSize.height + pRadius || particle.velocity.y < 0 && particle.position.y >= -pRadius || particle.velocity.x > 0 && particle.position.x <= canvasSize.width + pRadius || particle.velocity.x < 0 && particle.position.x >= -pRadius) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (!(0,engine_root_window_.isPointInside)(particle.position, container.canvas.size, engine_root_window_.Vector.origin, pRadius, direction)) {
|
|
270
|
+
container.particles.remove(particle);
|
|
271
|
+
}
|
|
272
|
+
} else {
|
|
273
|
+
const position = particle.position;
|
|
274
|
+
if (!gravityOptions.inverse && position.y > canvasSize.height + pRadius && direction === "bottom" || gravityOptions.inverse && position.y < -pRadius && direction === "top") {
|
|
275
|
+
container.particles.remove(particle);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
;// CONCATENATED MODULE: ./dist/browser/OutOutMode.js
|
|
281
|
+
|
|
282
|
+
class OutOutMode {
|
|
283
|
+
constructor(container) {
|
|
284
|
+
this.container = container;
|
|
285
|
+
this.modes = ["out"];
|
|
286
|
+
}
|
|
287
|
+
update(particle, direction, delta, outMode) {
|
|
288
|
+
if (!this.modes.includes(outMode)) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const container = this.container;
|
|
292
|
+
switch (particle.outType) {
|
|
293
|
+
case "inside":
|
|
294
|
+
{
|
|
295
|
+
const {
|
|
296
|
+
x: vx,
|
|
297
|
+
y: vy
|
|
298
|
+
} = particle.velocity;
|
|
299
|
+
const circVec = engine_root_window_.Vector.origin;
|
|
300
|
+
circVec.length = particle.moveCenter.radius;
|
|
301
|
+
circVec.angle = particle.velocity.angle + Math.PI;
|
|
302
|
+
circVec.addTo(engine_root_window_.Vector.create(particle.moveCenter));
|
|
303
|
+
const {
|
|
304
|
+
dx,
|
|
305
|
+
dy
|
|
306
|
+
} = (0,engine_root_window_.getDistances)(particle.position, circVec);
|
|
307
|
+
if (vx <= 0 && dx >= 0 || vy <= 0 && dy >= 0 || vx >= 0 && dx <= 0 || vy >= 0 && dy <= 0) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
particle.position.x = Math.floor((0,engine_root_window_.randomInRange)({
|
|
311
|
+
min: 0,
|
|
312
|
+
max: container.canvas.size.width
|
|
313
|
+
}));
|
|
314
|
+
particle.position.y = Math.floor((0,engine_root_window_.randomInRange)({
|
|
315
|
+
min: 0,
|
|
316
|
+
max: container.canvas.size.height
|
|
317
|
+
}));
|
|
318
|
+
const {
|
|
319
|
+
dx: newDx,
|
|
320
|
+
dy: newDy
|
|
321
|
+
} = (0,engine_root_window_.getDistances)(particle.position, particle.moveCenter);
|
|
322
|
+
particle.direction = Math.atan2(-newDy, -newDx);
|
|
323
|
+
particle.velocity.angle = particle.direction;
|
|
324
|
+
break;
|
|
325
|
+
}
|
|
326
|
+
default:
|
|
327
|
+
{
|
|
328
|
+
if ((0,engine_root_window_.isPointInside)(particle.position, container.canvas.size, engine_root_window_.Vector.origin, particle.getRadius(), direction)) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
switch (particle.outType) {
|
|
332
|
+
case "outside":
|
|
333
|
+
{
|
|
334
|
+
particle.position.x = Math.floor((0,engine_root_window_.randomInRange)({
|
|
335
|
+
min: -particle.moveCenter.radius,
|
|
336
|
+
max: particle.moveCenter.radius
|
|
337
|
+
})) + particle.moveCenter.x;
|
|
338
|
+
particle.position.y = Math.floor((0,engine_root_window_.randomInRange)({
|
|
339
|
+
min: -particle.moveCenter.radius,
|
|
340
|
+
max: particle.moveCenter.radius
|
|
341
|
+
})) + particle.moveCenter.y;
|
|
342
|
+
const {
|
|
343
|
+
dx,
|
|
344
|
+
dy
|
|
345
|
+
} = (0,engine_root_window_.getDistances)(particle.position, particle.moveCenter);
|
|
346
|
+
if (particle.moveCenter.radius) {
|
|
347
|
+
particle.direction = Math.atan2(dy, dx);
|
|
348
|
+
particle.velocity.angle = particle.direction;
|
|
349
|
+
}
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
case "normal":
|
|
353
|
+
{
|
|
354
|
+
const wrap = particle.options.move.warp,
|
|
355
|
+
canvasSize = container.canvas.size,
|
|
356
|
+
newPos = {
|
|
357
|
+
bottom: canvasSize.height + particle.getRadius() + particle.offset.y,
|
|
358
|
+
left: -particle.getRadius() - particle.offset.x,
|
|
359
|
+
right: canvasSize.width + particle.getRadius() + particle.offset.x,
|
|
360
|
+
top: -particle.getRadius() - particle.offset.y
|
|
361
|
+
},
|
|
362
|
+
sizeValue = particle.getRadius(),
|
|
363
|
+
nextBounds = (0,engine_root_window_.calculateBounds)(particle.position, sizeValue);
|
|
364
|
+
if (direction === "right" && nextBounds.left > canvasSize.width + particle.offset.x) {
|
|
365
|
+
particle.position.x = newPos.left;
|
|
366
|
+
particle.initialPosition.x = particle.position.x;
|
|
367
|
+
if (!wrap) {
|
|
368
|
+
particle.position.y = (0,engine_root_window_.getRandom)() * canvasSize.height;
|
|
369
|
+
particle.initialPosition.y = particle.position.y;
|
|
370
|
+
}
|
|
371
|
+
} else if (direction === "left" && nextBounds.right < -particle.offset.x) {
|
|
372
|
+
particle.position.x = newPos.right;
|
|
373
|
+
particle.initialPosition.x = particle.position.x;
|
|
374
|
+
if (!wrap) {
|
|
375
|
+
particle.position.y = (0,engine_root_window_.getRandom)() * canvasSize.height;
|
|
376
|
+
particle.initialPosition.y = particle.position.y;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (direction === "bottom" && nextBounds.top > canvasSize.height + particle.offset.y) {
|
|
380
|
+
if (!wrap) {
|
|
381
|
+
particle.position.x = (0,engine_root_window_.getRandom)() * canvasSize.width;
|
|
382
|
+
particle.initialPosition.x = particle.position.x;
|
|
383
|
+
}
|
|
384
|
+
particle.position.y = newPos.top;
|
|
385
|
+
particle.initialPosition.y = particle.position.y;
|
|
386
|
+
} else if (direction === "top" && nextBounds.bottom < -particle.offset.y) {
|
|
387
|
+
if (!wrap) {
|
|
388
|
+
particle.position.x = (0,engine_root_window_.getRandom)() * canvasSize.width;
|
|
389
|
+
particle.initialPosition.x = particle.position.x;
|
|
390
|
+
}
|
|
391
|
+
particle.position.y = newPos.bottom;
|
|
392
|
+
particle.initialPosition.y = particle.position.y;
|
|
393
|
+
}
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
;// CONCATENATED MODULE: ./dist/browser/OutOfCanvasUpdater.js
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
class OutOfCanvasUpdater {
|
|
408
|
+
constructor(container) {
|
|
409
|
+
this.container = container;
|
|
410
|
+
this.updaters = [new BounceOutMode(container), new DestroyOutMode(container), new OutOutMode(container), new NoneOutMode(container)];
|
|
411
|
+
}
|
|
412
|
+
init() {}
|
|
413
|
+
isEnabled(particle) {
|
|
414
|
+
return !particle.destroyed && !particle.spawning;
|
|
415
|
+
}
|
|
416
|
+
update(particle, delta) {
|
|
417
|
+
var _a, _b, _c, _d;
|
|
418
|
+
const outModes = particle.options.move.outModes;
|
|
419
|
+
this.updateOutMode(particle, delta, (_a = outModes.bottom) !== null && _a !== void 0 ? _a : outModes.default, "bottom");
|
|
420
|
+
this.updateOutMode(particle, delta, (_b = outModes.left) !== null && _b !== void 0 ? _b : outModes.default, "left");
|
|
421
|
+
this.updateOutMode(particle, delta, (_c = outModes.right) !== null && _c !== void 0 ? _c : outModes.default, "right");
|
|
422
|
+
this.updateOutMode(particle, delta, (_d = outModes.top) !== null && _d !== void 0 ? _d : outModes.default, "top");
|
|
423
|
+
}
|
|
424
|
+
updateOutMode(particle, delta, outMode, direction) {
|
|
425
|
+
for (const updater of this.updaters) {
|
|
426
|
+
updater.update(particle, direction, delta, outMode);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
431
|
+
|
|
432
|
+
async function loadOutModesUpdater(engine) {
|
|
433
|
+
await engine.addParticleUpdater("outModes", container => new OutOfCanvasUpdater(container));
|
|
434
|
+
}
|
|
435
|
+
})();
|
|
436
|
+
|
|
437
|
+
/******/ return __webpack_exports__;
|
|
438
|
+
/******/ })()
|
|
439
|
+
;
|
|
440
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see tsparticles.updater.out-modes.min.js.LICENSE.txt */
|
|
2
|
+
!function(t,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],o);else{var e="object"==typeof exports?o(require("@tsparticles/engine")):o(t.window);for(var i in e)("object"==typeof exports?exports:t)[i]=e[i]}}(this,(t=>(()=>{"use strict";var o={533:o=>{o.exports=t}},e={};function i(t){var n=e[t];if(void 0!==n)return n.exports;var s=e[t]={exports:{}};return o[t](s,s.exports,i),s.exports}i.d=(t,o)=>{for(var e in o)i.o(o,e)&&!i.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:o[e]})},i.o=(t,o)=>Object.prototype.hasOwnProperty.call(t,o),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{i.r(n),i.d(n,{loadOutModesUpdater:()=>c});var t=i(533);class o{constructor(t){this.container=t,this.modes=["bounce","bounce-vertical","bounce-horizontal","bounceVertical","bounceHorizontal","split"]}update(o,e,i,n){if(!this.modes.includes(n))return;const s=this.container;let a=!1;for(const[,t]of s.plugins)if(void 0!==t.particleBounce&&(a=t.particleBounce(o,i,e)),a)break;if(a)return;const r=o.getPosition(),c=o.offset,d=o.getRadius(),u=(0,t.calculateBounds)(r,d),l=s.canvas.size;!function(o){if("bounce"!==o.outMode&&"bounce-horizontal"!==o.outMode&&"bounceHorizontal"!==o.outMode&&"split"!==o.outMode)return;o.bounds.right<0?o.particle.position.x=o.size+o.offset.x:o.bounds.left>o.canvasSize.width&&(o.particle.position.x=o.canvasSize.width-o.size-o.offset.x);const e=o.particle.velocity.x;let i=!1;if("right"===o.direction&&o.bounds.right>=o.canvasSize.width&&e>0||"left"===o.direction&&o.bounds.left<=0&&e<0){const e=(0,t.getValue)(o.particle.options.bounce.horizontal);o.particle.velocity.x*=-e,i=!0}if(!i)return;const n=o.offset.x+o.size;o.bounds.right>=o.canvasSize.width?o.particle.position.x=o.canvasSize.width-n:o.bounds.left<=0&&(o.particle.position.x=n),"split"===o.outMode&&o.particle.destroy()}({particle:o,outMode:n,direction:e,bounds:u,canvasSize:l,offset:c,size:d}),function(o){if("bounce"!==o.outMode&&"bounce-vertical"!==o.outMode&&"bounceVertical"!==o.outMode&&"split"!==o.outMode)return;o.bounds.bottom<0?o.particle.position.y=o.size+o.offset.y:o.bounds.top>o.canvasSize.height&&(o.particle.position.y=o.canvasSize.height-o.size-o.offset.y);const e=o.particle.velocity.y;let i=!1;if("bottom"===o.direction&&o.bounds.bottom>=o.canvasSize.height&&e>0||"top"===o.direction&&o.bounds.top<=0&&e<0){const e=(0,t.getValue)(o.particle.options.bounce.vertical);o.particle.velocity.y*=-e,i=!0}if(!i)return;const n=o.offset.y+o.size;o.bounds.bottom>=o.canvasSize.height?o.particle.position.y=o.canvasSize.height-n:o.bounds.top<=0&&(o.particle.position.y=n),"split"===o.outMode&&o.particle.destroy()}({particle:o,outMode:n,direction:e,bounds:u,canvasSize:l,offset:c,size:d})}}class e{constructor(t){this.container=t,this.modes=["destroy"]}update(o,e,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(o.outType){case"normal":case"outside":if((0,t.isPointInside)(o.position,s.canvas.size,t.Vector.origin,o.getRadius(),e))return;break;case"inside":{const{dx:e,dy:i}=(0,t.getDistances)(o.position,o.moveCenter),{x:n,y:s}=o.velocity;if(n<0&&e>o.moveCenter.radius||s<0&&i>o.moveCenter.radius||n>=0&&e<-o.moveCenter.radius||s>=0&&i<-o.moveCenter.radius)return;break}}s.particles.remove(o,void 0,!0)}}class s{constructor(t){this.container=t,this.modes=["none"]}update(o,e,i,n){if(!this.modes.includes(n))return;if(o.options.move.distance.horizontal&&("left"===e||"right"===e)||o.options.move.distance.vertical&&("top"===e||"bottom"===e))return;const s=o.options.move.gravity,a=this.container,r=a.canvas.size,c=o.getRadius();if(s.enable){const t=o.position;(!s.inverse&&t.y>r.height+c&&"bottom"===e||s.inverse&&t.y<-c&&"top"===e)&&a.particles.remove(o)}else{if(o.velocity.y>0&&o.position.y<=r.height+c||o.velocity.y<0&&o.position.y>=-c||o.velocity.x>0&&o.position.x<=r.width+c||o.velocity.x<0&&o.position.x>=-c)return;(0,t.isPointInside)(o.position,a.canvas.size,t.Vector.origin,c,e)||a.particles.remove(o)}}}class a{constructor(t){this.container=t,this.modes=["out"]}update(o,e,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(o.outType){case"inside":{const{x:e,y:i}=o.velocity,n=t.Vector.origin;n.length=o.moveCenter.radius,n.angle=o.velocity.angle+Math.PI,n.addTo(t.Vector.create(o.moveCenter));const{dx:a,dy:r}=(0,t.getDistances)(o.position,n);if(e<=0&&a>=0||i<=0&&r>=0||e>=0&&a<=0||i>=0&&r<=0)return;o.position.x=Math.floor((0,t.randomInRange)({min:0,max:s.canvas.size.width})),o.position.y=Math.floor((0,t.randomInRange)({min:0,max:s.canvas.size.height}));const{dx:c,dy:d}=(0,t.getDistances)(o.position,o.moveCenter);o.direction=Math.atan2(-d,-c),o.velocity.angle=o.direction;break}default:if((0,t.isPointInside)(o.position,s.canvas.size,t.Vector.origin,o.getRadius(),e))return;switch(o.outType){case"outside":{o.position.x=Math.floor((0,t.randomInRange)({min:-o.moveCenter.radius,max:o.moveCenter.radius}))+o.moveCenter.x,o.position.y=Math.floor((0,t.randomInRange)({min:-o.moveCenter.radius,max:o.moveCenter.radius}))+o.moveCenter.y;const{dx:e,dy:i}=(0,t.getDistances)(o.position,o.moveCenter);o.moveCenter.radius&&(o.direction=Math.atan2(i,e),o.velocity.angle=o.direction);break}case"normal":{const i=o.options.move.warp,n=s.canvas.size,a={bottom:n.height+o.getRadius()+o.offset.y,left:-o.getRadius()-o.offset.x,right:n.width+o.getRadius()+o.offset.x,top:-o.getRadius()-o.offset.y},r=o.getRadius(),c=(0,t.calculateBounds)(o.position,r);"right"===e&&c.left>n.width+o.offset.x?(o.position.x=a.left,o.initialPosition.x=o.position.x,i||(o.position.y=(0,t.getRandom)()*n.height,o.initialPosition.y=o.position.y)):"left"===e&&c.right<-o.offset.x&&(o.position.x=a.right,o.initialPosition.x=o.position.x,i||(o.position.y=(0,t.getRandom)()*n.height,o.initialPosition.y=o.position.y)),"bottom"===e&&c.top>n.height+o.offset.y?(i||(o.position.x=(0,t.getRandom)()*n.width,o.initialPosition.x=o.position.x),o.position.y=a.top,o.initialPosition.y=o.position.y):"top"===e&&c.bottom<-o.offset.y&&(i||(o.position.x=(0,t.getRandom)()*n.width,o.initialPosition.x=o.position.x),o.position.y=a.bottom,o.initialPosition.y=o.position.y);break}}}}}class r{constructor(t){this.container=t,this.updaters=[new o(t),new e(t),new a(t),new s(t)]}init(){}isEnabled(t){return!t.destroyed&&!t.spawning}update(t,o){var e,i,n,s;const a=t.options.move.outModes;this.updateOutMode(t,o,null!==(e=a.bottom)&&void 0!==e?e:a.default,"bottom"),this.updateOutMode(t,o,null!==(i=a.left)&&void 0!==i?i:a.default,"left"),this.updateOutMode(t,o,null!==(n=a.right)&&void 0!==n?n:a.default,"right"),this.updateOutMode(t,o,null!==(s=a.top)&&void 0!==s?s:a.default,"top")}updateOutMode(t,o,e,i){for(const n of this.updaters)n.update(t,i,o,e)}}async function c(t){await t.addParticleUpdater("outModes",(t=>new r(t)))}})(),n})()));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Container, IDelta, OutModeAlt, OutModeDirection, Particle } from "@tsparticles/engine";
|
|
2
|
+
import { OutMode } from "@tsparticles/engine";
|
|
3
|
+
import type { IOutModeManager } from "./IOutModeManager";
|
|
4
|
+
export declare class BounceOutMode implements IOutModeManager {
|
|
5
|
+
private readonly container;
|
|
6
|
+
modes: (OutMode | OutModeAlt | keyof typeof OutMode)[];
|
|
7
|
+
constructor(container: Container);
|
|
8
|
+
update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Container, IDelta, OutModeAlt, OutModeDirection, Particle } from "@tsparticles/engine";
|
|
2
|
+
import { OutMode } from "@tsparticles/engine";
|
|
3
|
+
import type { IOutModeManager } from "./IOutModeManager";
|
|
4
|
+
export declare class DestroyOutMode implements IOutModeManager {
|
|
5
|
+
private readonly container;
|
|
6
|
+
modes: (OutMode | OutModeAlt | keyof typeof OutMode)[];
|
|
7
|
+
constructor(container: Container);
|
|
8
|
+
update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IBounds, ICoordinates, IDimension, OutMode, OutModeAlt, OutModeDirection } from "@tsparticles/engine";
|
|
2
|
+
import type { Particle } from "@tsparticles/engine";
|
|
3
|
+
export interface IBounceData {
|
|
4
|
+
bounds: IBounds;
|
|
5
|
+
canvasSize: IDimension;
|
|
6
|
+
direction: OutModeDirection;
|
|
7
|
+
offset: ICoordinates;
|
|
8
|
+
outMode: OutMode | OutModeAlt | keyof typeof OutMode;
|
|
9
|
+
particle: Particle;
|
|
10
|
+
size: number;
|
|
11
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IDelta, OutMode, OutModeAlt, OutModeDirection, Particle } from "@tsparticles/engine";
|
|
2
|
+
export interface IOutModeManager {
|
|
3
|
+
modes: (OutMode | OutModeAlt | keyof typeof OutMode)[];
|
|
4
|
+
update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void;
|
|
5
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Container, IDelta, OutModeAlt, Particle } from "@tsparticles/engine";
|
|
2
|
+
import { OutMode, OutModeDirection } from "@tsparticles/engine";
|
|
3
|
+
import type { IOutModeManager } from "./IOutModeManager";
|
|
4
|
+
export declare class NoneOutMode implements IOutModeManager {
|
|
5
|
+
private readonly container;
|
|
6
|
+
modes: (OutMode | OutModeAlt | keyof typeof OutMode)[];
|
|
7
|
+
constructor(container: Container);
|
|
8
|
+
update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Container, IDelta, IParticleUpdater, Particle } from "@tsparticles/engine";
|
|
2
|
+
import type { IOutModeManager } from "./IOutModeManager";
|
|
3
|
+
export declare class OutOfCanvasUpdater implements IParticleUpdater {
|
|
4
|
+
private readonly container;
|
|
5
|
+
updaters: IOutModeManager[];
|
|
6
|
+
constructor(container: Container);
|
|
7
|
+
init(): void;
|
|
8
|
+
isEnabled(particle: Particle): boolean;
|
|
9
|
+
update(particle: Particle, delta: IDelta): void;
|
|
10
|
+
private updateOutMode;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Container, IDelta, OutModeAlt, Particle } from "@tsparticles/engine";
|
|
2
|
+
import { OutMode, OutModeDirection } from "@tsparticles/engine";
|
|
3
|
+
import type { IOutModeManager } from "./IOutModeManager";
|
|
4
|
+
export declare class OutOutMode implements IOutModeManager {
|
|
5
|
+
private readonly container;
|
|
6
|
+
modes: (OutMode | OutModeAlt | keyof typeof OutMode)[];
|
|
7
|
+
constructor(container: Container);
|
|
8
|
+
update(particle: Particle, direction: OutModeDirection, delta: IDelta, outMode: OutMode | OutModeAlt | keyof typeof OutMode): void;
|
|
9
|
+
}
|
package/types/Utils.d.ts
ADDED
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
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", "./Utils"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BounceOutMode = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const Utils_1 = require("./Utils");
|
|
15
|
+
class BounceOutMode {
|
|
16
|
+
constructor(container) {
|
|
17
|
+
this.container = container;
|
|
18
|
+
this.modes = [
|
|
19
|
+
"bounce",
|
|
20
|
+
"bounce-vertical",
|
|
21
|
+
"bounce-horizontal",
|
|
22
|
+
"bounceVertical",
|
|
23
|
+
"bounceHorizontal",
|
|
24
|
+
"split",
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
update(particle, direction, delta, outMode) {
|
|
28
|
+
if (!this.modes.includes(outMode)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const container = this.container;
|
|
32
|
+
let handled = false;
|
|
33
|
+
for (const [, plugin] of container.plugins) {
|
|
34
|
+
if (plugin.particleBounce !== undefined) {
|
|
35
|
+
handled = plugin.particleBounce(particle, delta, direction);
|
|
36
|
+
}
|
|
37
|
+
if (handled) {
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (handled) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const pos = particle.getPosition(), offset = particle.offset, size = particle.getRadius(), bounds = (0, engine_1.calculateBounds)(pos, size), canvasSize = container.canvas.size;
|
|
45
|
+
(0, Utils_1.bounceHorizontal)({ particle, outMode, direction, bounds, canvasSize, offset, size });
|
|
46
|
+
(0, Utils_1.bounceVertical)({ particle, outMode, direction, bounds, canvasSize, offset, size });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.BounceOutMode = BounceOutMode;
|
|
50
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
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.DestroyOutMode = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
class DestroyOutMode {
|
|
15
|
+
constructor(container) {
|
|
16
|
+
this.container = container;
|
|
17
|
+
this.modes = ["destroy"];
|
|
18
|
+
}
|
|
19
|
+
update(particle, direction, delta, outMode) {
|
|
20
|
+
if (!this.modes.includes(outMode)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const container = this.container;
|
|
24
|
+
switch (particle.outType) {
|
|
25
|
+
case "normal":
|
|
26
|
+
case "outside":
|
|
27
|
+
if ((0, engine_1.isPointInside)(particle.position, container.canvas.size, engine_1.Vector.origin, particle.getRadius(), direction)) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
break;
|
|
31
|
+
case "inside": {
|
|
32
|
+
const { dx, dy } = (0, engine_1.getDistances)(particle.position, particle.moveCenter);
|
|
33
|
+
const { x: vx, y: vy } = particle.velocity;
|
|
34
|
+
if ((vx < 0 && dx > particle.moveCenter.radius) ||
|
|
35
|
+
(vy < 0 && dy > particle.moveCenter.radius) ||
|
|
36
|
+
(vx >= 0 && dx < -particle.moveCenter.radius) ||
|
|
37
|
+
(vy >= 0 && dy < -particle.moveCenter.radius)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
container.particles.remove(particle, undefined, true);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.DestroyOutMode = DestroyOutMode;
|
|
47
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
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"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|