@tsparticles/updater-out-modes 3.0.3 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/DestroyOutMode.js +5 -4
- package/browser/NoneOutMode.js +6 -5
- package/browser/OutOfCanvasUpdater.js +1 -1
- package/browser/OutOutMode.js +5 -1
- package/browser/Utils.js +13 -8
- package/cjs/DestroyOutMode.js +5 -4
- package/cjs/NoneOutMode.js +6 -5
- package/cjs/OutOfCanvasUpdater.js +1 -1
- package/cjs/OutOutMode.js +5 -1
- package/cjs/Utils.js +13 -8
- package/esm/DestroyOutMode.js +5 -4
- package/esm/NoneOutMode.js +6 -5
- package/esm/OutOfCanvasUpdater.js +1 -1
- package/esm/OutOutMode.js +5 -1
- package/esm/Utils.js +13 -8
- package/package.json +2 -2
- package/report.html +2 -2
- package/tsparticles.updater.out-modes.js +18 -12
- package/tsparticles.updater.out-modes.min.js +1 -1
- package/tsparticles.updater.out-modes.min.js.LICENSE.txt +1 -1
- package/types/OutOfCanvasUpdater.d.ts +1 -1
- package/umd/DestroyOutMode.js +5 -4
- package/umd/NoneOutMode.js +6 -5
- package/umd/OutOfCanvasUpdater.js +1 -1
- package/umd/OutOutMode.js +5 -1
- package/umd/Utils.js +13 -8
|
@@ -1,4 +1,5 @@
|
|
|
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;
|
|
@@ -19,10 +20,10 @@ export class DestroyOutMode {
|
|
|
19
20
|
case "inside": {
|
|
20
21
|
const { dx, dy } = getDistances(particle.position, particle.moveCenter);
|
|
21
22
|
const { x: vx, y: vy } = particle.velocity;
|
|
22
|
-
if ((vx <
|
|
23
|
-
(vy <
|
|
24
|
-
(vx >=
|
|
25
|
-
(vy >=
|
|
23
|
+
if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
|
|
24
|
+
(vy < minVelocity && dy > particle.moveCenter.radius) ||
|
|
25
|
+
(vx >= minVelocity && dx < -particle.moveCenter.radius) ||
|
|
26
|
+
(vy >= minVelocity && dy < -particle.moveCenter.radius)) {
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
29
|
break;
|
package/browser/NoneOutMode.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
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;
|
|
@@ -9,7 +10,7 @@ export class NoneOutMode {
|
|
|
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;
|
|
@@ -18,10 +19,10 @@ export class NoneOutMode {
|
|
|
18
19
|
const canvasSize = container.canvas.size;
|
|
19
20
|
const pRadius = particle.getRadius();
|
|
20
21
|
if (!gravityOptions.enable) {
|
|
21
|
-
if ((particle.velocity.y >
|
|
22
|
-
(particle.velocity.y <
|
|
23
|
-
(particle.velocity.x >
|
|
24
|
-
(particle.velocity.x <
|
|
22
|
+
if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) ||
|
|
23
|
+
(particle.velocity.y < minVelocity && particle.position.y >= -pRadius) ||
|
|
24
|
+
(particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius) ||
|
|
25
|
+
(particle.velocity.x < minVelocity && particle.position.x >= -pRadius)) {
|
|
25
26
|
return;
|
|
26
27
|
}
|
|
27
28
|
if (!isPointInside(particle.position, container.canvas.size, Vector.origin, pRadius, direction)) {
|
|
@@ -4,12 +4,12 @@ import { NoneOutMode } from "./NoneOutMode.js";
|
|
|
4
4
|
import { OutOutMode } from "./OutOutMode.js";
|
|
5
5
|
export class OutOfCanvasUpdater {
|
|
6
6
|
constructor(container) {
|
|
7
|
-
this.container = container;
|
|
8
7
|
this._updateOutMode = (particle, delta, outMode, direction) => {
|
|
9
8
|
for (const updater of this.updaters) {
|
|
10
9
|
updater.update(particle, direction, delta, outMode);
|
|
11
10
|
}
|
|
12
11
|
};
|
|
12
|
+
this.container = container;
|
|
13
13
|
this.updaters = [
|
|
14
14
|
new BounceOutMode(container),
|
|
15
15
|
new DestroyOutMode(container),
|
package/browser/OutOutMode.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
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;
|
|
@@ -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({
|
package/browser/Utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getRangeValue } from "@tsparticles/engine";
|
|
2
|
+
const minVelocity = 0, boundsMin = 0;
|
|
2
3
|
export function bounceHorizontal(data) {
|
|
3
4
|
if ((data.outMode !== "bounce" &&
|
|
4
5
|
data.outMode !== "bounce-horizontal" &&
|
|
@@ -7,7 +8,7 @@ export function bounceHorizontal(data) {
|
|
|
7
8
|
(data.direction !== "left" && data.direction !== "right")) {
|
|
8
9
|
return;
|
|
9
10
|
}
|
|
10
|
-
if (data.bounds.right <
|
|
11
|
+
if (data.bounds.right < boundsMin && data.direction === "left") {
|
|
11
12
|
data.particle.position.x = data.size + data.offset.x;
|
|
12
13
|
}
|
|
13
14
|
else if (data.bounds.left > data.canvasSize.width && data.direction === "right") {
|
|
@@ -15,8 +16,10 @@ export function bounceHorizontal(data) {
|
|
|
15
16
|
}
|
|
16
17
|
const velocity = data.particle.velocity.x;
|
|
17
18
|
let bounced = false;
|
|
18
|
-
if ((data.direction === "right" &&
|
|
19
|
-
|
|
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)) {
|
|
20
23
|
const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);
|
|
21
24
|
data.particle.velocity.x *= -newVelocity;
|
|
22
25
|
bounced = true;
|
|
@@ -28,7 +31,7 @@ export function bounceHorizontal(data) {
|
|
|
28
31
|
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") {
|
|
29
32
|
data.particle.position.x = data.canvasSize.width - minPos;
|
|
30
33
|
}
|
|
31
|
-
else if (data.bounds.left <=
|
|
34
|
+
else if (data.bounds.left <= boundsMin && data.direction === "left") {
|
|
32
35
|
data.particle.position.x = minPos;
|
|
33
36
|
}
|
|
34
37
|
if (data.outMode === "split") {
|
|
@@ -43,7 +46,7 @@ export function bounceVertical(data) {
|
|
|
43
46
|
(data.direction !== "bottom" && data.direction !== "top")) {
|
|
44
47
|
return;
|
|
45
48
|
}
|
|
46
|
-
if (data.bounds.bottom <
|
|
49
|
+
if (data.bounds.bottom < boundsMin && data.direction === "top") {
|
|
47
50
|
data.particle.position.y = data.size + data.offset.y;
|
|
48
51
|
}
|
|
49
52
|
else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") {
|
|
@@ -51,8 +54,10 @@ export function bounceVertical(data) {
|
|
|
51
54
|
}
|
|
52
55
|
const velocity = data.particle.velocity.y;
|
|
53
56
|
let bounced = false;
|
|
54
|
-
if ((data.direction === "bottom" &&
|
|
55
|
-
|
|
57
|
+
if ((data.direction === "bottom" &&
|
|
58
|
+
data.bounds.bottom >= data.canvasSize.height &&
|
|
59
|
+
velocity > minVelocity) ||
|
|
60
|
+
(data.direction === "top" && data.bounds.top <= boundsMin && velocity < minVelocity)) {
|
|
56
61
|
const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);
|
|
57
62
|
data.particle.velocity.y *= -newVelocity;
|
|
58
63
|
bounced = true;
|
|
@@ -64,7 +69,7 @@ export function bounceVertical(data) {
|
|
|
64
69
|
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") {
|
|
65
70
|
data.particle.position.y = data.canvasSize.height - minPos;
|
|
66
71
|
}
|
|
67
|
-
else if (data.bounds.top <=
|
|
72
|
+
else if (data.bounds.top <= boundsMin && data.direction === "top") {
|
|
68
73
|
data.particle.position.y = minPos;
|
|
69
74
|
}
|
|
70
75
|
if (data.outMode === "split") {
|
package/cjs/DestroyOutMode.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DestroyOutMode = void 0;
|
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
|
+
const minVelocity = 0;
|
|
5
6
|
class DestroyOutMode {
|
|
6
7
|
constructor(container) {
|
|
7
8
|
this.container = container;
|
|
@@ -22,10 +23,10 @@ class DestroyOutMode {
|
|
|
22
23
|
case "inside": {
|
|
23
24
|
const { dx, dy } = (0, engine_1.getDistances)(particle.position, particle.moveCenter);
|
|
24
25
|
const { x: vx, y: vy } = particle.velocity;
|
|
25
|
-
if ((vx <
|
|
26
|
-
(vy <
|
|
27
|
-
(vx >=
|
|
28
|
-
(vy >=
|
|
26
|
+
if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
|
|
27
|
+
(vy < minVelocity && dy > particle.moveCenter.radius) ||
|
|
28
|
+
(vx >= minVelocity && dx < -particle.moveCenter.radius) ||
|
|
29
|
+
(vy >= minVelocity && dy < -particle.moveCenter.radius)) {
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
31
32
|
break;
|
package/cjs/NoneOutMode.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NoneOutMode = void 0;
|
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
|
+
const minVelocity = 0;
|
|
5
6
|
class NoneOutMode {
|
|
6
7
|
constructor(container) {
|
|
7
8
|
this.container = container;
|
|
@@ -12,7 +13,7 @@ class NoneOutMode {
|
|
|
12
13
|
return;
|
|
13
14
|
}
|
|
14
15
|
if ((particle.options.move.distance.horizontal &&
|
|
15
|
-
(direction === "left" || direction === "right"))
|
|
16
|
+
(direction === "left" || direction === "right")) ??
|
|
16
17
|
(particle.options.move.distance.vertical &&
|
|
17
18
|
(direction === "top" || direction === "bottom"))) {
|
|
18
19
|
return;
|
|
@@ -21,10 +22,10 @@ class NoneOutMode {
|
|
|
21
22
|
const canvasSize = container.canvas.size;
|
|
22
23
|
const pRadius = particle.getRadius();
|
|
23
24
|
if (!gravityOptions.enable) {
|
|
24
|
-
if ((particle.velocity.y >
|
|
25
|
-
(particle.velocity.y <
|
|
26
|
-
(particle.velocity.x >
|
|
27
|
-
(particle.velocity.x <
|
|
25
|
+
if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) ||
|
|
26
|
+
(particle.velocity.y < minVelocity && particle.position.y >= -pRadius) ||
|
|
27
|
+
(particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius) ||
|
|
28
|
+
(particle.velocity.x < minVelocity && particle.position.x >= -pRadius)) {
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
31
|
if (!(0, engine_1.isPointInside)(particle.position, container.canvas.size, engine_1.Vector.origin, pRadius, direction)) {
|
|
@@ -7,12 +7,12 @@ const NoneOutMode_js_1 = require("./NoneOutMode.js");
|
|
|
7
7
|
const OutOutMode_js_1 = require("./OutOutMode.js");
|
|
8
8
|
class OutOfCanvasUpdater {
|
|
9
9
|
constructor(container) {
|
|
10
|
-
this.container = container;
|
|
11
10
|
this._updateOutMode = (particle, delta, outMode, direction) => {
|
|
12
11
|
for (const updater of this.updaters) {
|
|
13
12
|
updater.update(particle, direction, delta, outMode);
|
|
14
13
|
}
|
|
15
14
|
};
|
|
15
|
+
this.container = container;
|
|
16
16
|
this.updaters = [
|
|
17
17
|
new BounceOutMode_js_1.BounceOutMode(container),
|
|
18
18
|
new DestroyOutMode_js_1.DestroyOutMode(container),
|
package/cjs/OutOutMode.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
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;
|
|
@@ -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)({
|
package/cjs/Utils.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
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
7
|
if ((data.outMode !== "bounce" &&
|
|
7
8
|
data.outMode !== "bounce-horizontal" &&
|
|
@@ -10,7 +11,7 @@ function bounceHorizontal(data) {
|
|
|
10
11
|
(data.direction !== "left" && data.direction !== "right")) {
|
|
11
12
|
return;
|
|
12
13
|
}
|
|
13
|
-
if (data.bounds.right <
|
|
14
|
+
if (data.bounds.right < boundsMin && data.direction === "left") {
|
|
14
15
|
data.particle.position.x = data.size + data.offset.x;
|
|
15
16
|
}
|
|
16
17
|
else if (data.bounds.left > data.canvasSize.width && data.direction === "right") {
|
|
@@ -18,8 +19,10 @@ function bounceHorizontal(data) {
|
|
|
18
19
|
}
|
|
19
20
|
const velocity = data.particle.velocity.x;
|
|
20
21
|
let bounced = false;
|
|
21
|
-
if ((data.direction === "right" &&
|
|
22
|
-
|
|
22
|
+
if ((data.direction === "right" &&
|
|
23
|
+
data.bounds.right >= data.canvasSize.width &&
|
|
24
|
+
velocity > minVelocity) ||
|
|
25
|
+
(data.direction === "left" && data.bounds.left <= boundsMin && velocity < minVelocity)) {
|
|
23
26
|
const newVelocity = (0, engine_1.getRangeValue)(data.particle.options.bounce.horizontal.value);
|
|
24
27
|
data.particle.velocity.x *= -newVelocity;
|
|
25
28
|
bounced = true;
|
|
@@ -31,7 +34,7 @@ function bounceHorizontal(data) {
|
|
|
31
34
|
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") {
|
|
32
35
|
data.particle.position.x = data.canvasSize.width - minPos;
|
|
33
36
|
}
|
|
34
|
-
else if (data.bounds.left <=
|
|
37
|
+
else if (data.bounds.left <= boundsMin && data.direction === "left") {
|
|
35
38
|
data.particle.position.x = minPos;
|
|
36
39
|
}
|
|
37
40
|
if (data.outMode === "split") {
|
|
@@ -47,7 +50,7 @@ function bounceVertical(data) {
|
|
|
47
50
|
(data.direction !== "bottom" && data.direction !== "top")) {
|
|
48
51
|
return;
|
|
49
52
|
}
|
|
50
|
-
if (data.bounds.bottom <
|
|
53
|
+
if (data.bounds.bottom < boundsMin && data.direction === "top") {
|
|
51
54
|
data.particle.position.y = data.size + data.offset.y;
|
|
52
55
|
}
|
|
53
56
|
else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") {
|
|
@@ -55,8 +58,10 @@ function bounceVertical(data) {
|
|
|
55
58
|
}
|
|
56
59
|
const velocity = data.particle.velocity.y;
|
|
57
60
|
let bounced = false;
|
|
58
|
-
if ((data.direction === "bottom" &&
|
|
59
|
-
|
|
61
|
+
if ((data.direction === "bottom" &&
|
|
62
|
+
data.bounds.bottom >= data.canvasSize.height &&
|
|
63
|
+
velocity > minVelocity) ||
|
|
64
|
+
(data.direction === "top" && data.bounds.top <= boundsMin && velocity < minVelocity)) {
|
|
60
65
|
const newVelocity = (0, engine_1.getRangeValue)(data.particle.options.bounce.vertical.value);
|
|
61
66
|
data.particle.velocity.y *= -newVelocity;
|
|
62
67
|
bounced = true;
|
|
@@ -68,7 +73,7 @@ function bounceVertical(data) {
|
|
|
68
73
|
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") {
|
|
69
74
|
data.particle.position.y = data.canvasSize.height - minPos;
|
|
70
75
|
}
|
|
71
|
-
else if (data.bounds.top <=
|
|
76
|
+
else if (data.bounds.top <= boundsMin && data.direction === "top") {
|
|
72
77
|
data.particle.position.y = minPos;
|
|
73
78
|
}
|
|
74
79
|
if (data.outMode === "split") {
|
package/esm/DestroyOutMode.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
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;
|
|
@@ -19,10 +20,10 @@ export class DestroyOutMode {
|
|
|
19
20
|
case "inside": {
|
|
20
21
|
const { dx, dy } = getDistances(particle.position, particle.moveCenter);
|
|
21
22
|
const { x: vx, y: vy } = particle.velocity;
|
|
22
|
-
if ((vx <
|
|
23
|
-
(vy <
|
|
24
|
-
(vx >=
|
|
25
|
-
(vy >=
|
|
23
|
+
if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
|
|
24
|
+
(vy < minVelocity && dy > particle.moveCenter.radius) ||
|
|
25
|
+
(vx >= minVelocity && dx < -particle.moveCenter.radius) ||
|
|
26
|
+
(vy >= minVelocity && dy < -particle.moveCenter.radius)) {
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
29
|
break;
|
package/esm/NoneOutMode.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
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;
|
|
@@ -9,7 +10,7 @@ export class NoneOutMode {
|
|
|
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;
|
|
@@ -18,10 +19,10 @@ export class NoneOutMode {
|
|
|
18
19
|
const canvasSize = container.canvas.size;
|
|
19
20
|
const pRadius = particle.getRadius();
|
|
20
21
|
if (!gravityOptions.enable) {
|
|
21
|
-
if ((particle.velocity.y >
|
|
22
|
-
(particle.velocity.y <
|
|
23
|
-
(particle.velocity.x >
|
|
24
|
-
(particle.velocity.x <
|
|
22
|
+
if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) ||
|
|
23
|
+
(particle.velocity.y < minVelocity && particle.position.y >= -pRadius) ||
|
|
24
|
+
(particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius) ||
|
|
25
|
+
(particle.velocity.x < minVelocity && particle.position.x >= -pRadius)) {
|
|
25
26
|
return;
|
|
26
27
|
}
|
|
27
28
|
if (!isPointInside(particle.position, container.canvas.size, Vector.origin, pRadius, direction)) {
|
|
@@ -4,12 +4,12 @@ import { NoneOutMode } from "./NoneOutMode.js";
|
|
|
4
4
|
import { OutOutMode } from "./OutOutMode.js";
|
|
5
5
|
export class OutOfCanvasUpdater {
|
|
6
6
|
constructor(container) {
|
|
7
|
-
this.container = container;
|
|
8
7
|
this._updateOutMode = (particle, delta, outMode, direction) => {
|
|
9
8
|
for (const updater of this.updaters) {
|
|
10
9
|
updater.update(particle, direction, delta, outMode);
|
|
11
10
|
}
|
|
12
11
|
};
|
|
12
|
+
this.container = container;
|
|
13
13
|
this.updaters = [
|
|
14
14
|
new BounceOutMode(container),
|
|
15
15
|
new DestroyOutMode(container),
|
package/esm/OutOutMode.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
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;
|
|
@@ -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({
|
package/esm/Utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getRangeValue } from "@tsparticles/engine";
|
|
2
|
+
const minVelocity = 0, boundsMin = 0;
|
|
2
3
|
export function bounceHorizontal(data) {
|
|
3
4
|
if ((data.outMode !== "bounce" &&
|
|
4
5
|
data.outMode !== "bounce-horizontal" &&
|
|
@@ -7,7 +8,7 @@ export function bounceHorizontal(data) {
|
|
|
7
8
|
(data.direction !== "left" && data.direction !== "right")) {
|
|
8
9
|
return;
|
|
9
10
|
}
|
|
10
|
-
if (data.bounds.right <
|
|
11
|
+
if (data.bounds.right < boundsMin && data.direction === "left") {
|
|
11
12
|
data.particle.position.x = data.size + data.offset.x;
|
|
12
13
|
}
|
|
13
14
|
else if (data.bounds.left > data.canvasSize.width && data.direction === "right") {
|
|
@@ -15,8 +16,10 @@ export function bounceHorizontal(data) {
|
|
|
15
16
|
}
|
|
16
17
|
const velocity = data.particle.velocity.x;
|
|
17
18
|
let bounced = false;
|
|
18
|
-
if ((data.direction === "right" &&
|
|
19
|
-
|
|
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)) {
|
|
20
23
|
const newVelocity = getRangeValue(data.particle.options.bounce.horizontal.value);
|
|
21
24
|
data.particle.velocity.x *= -newVelocity;
|
|
22
25
|
bounced = true;
|
|
@@ -28,7 +31,7 @@ export function bounceHorizontal(data) {
|
|
|
28
31
|
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") {
|
|
29
32
|
data.particle.position.x = data.canvasSize.width - minPos;
|
|
30
33
|
}
|
|
31
|
-
else if (data.bounds.left <=
|
|
34
|
+
else if (data.bounds.left <= boundsMin && data.direction === "left") {
|
|
32
35
|
data.particle.position.x = minPos;
|
|
33
36
|
}
|
|
34
37
|
if (data.outMode === "split") {
|
|
@@ -43,7 +46,7 @@ export function bounceVertical(data) {
|
|
|
43
46
|
(data.direction !== "bottom" && data.direction !== "top")) {
|
|
44
47
|
return;
|
|
45
48
|
}
|
|
46
|
-
if (data.bounds.bottom <
|
|
49
|
+
if (data.bounds.bottom < boundsMin && data.direction === "top") {
|
|
47
50
|
data.particle.position.y = data.size + data.offset.y;
|
|
48
51
|
}
|
|
49
52
|
else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") {
|
|
@@ -51,8 +54,10 @@ export function bounceVertical(data) {
|
|
|
51
54
|
}
|
|
52
55
|
const velocity = data.particle.velocity.y;
|
|
53
56
|
let bounced = false;
|
|
54
|
-
if ((data.direction === "bottom" &&
|
|
55
|
-
|
|
57
|
+
if ((data.direction === "bottom" &&
|
|
58
|
+
data.bounds.bottom >= data.canvasSize.height &&
|
|
59
|
+
velocity > minVelocity) ||
|
|
60
|
+
(data.direction === "top" && data.bounds.top <= boundsMin && velocity < minVelocity)) {
|
|
56
61
|
const newVelocity = getRangeValue(data.particle.options.bounce.vertical.value);
|
|
57
62
|
data.particle.velocity.y *= -newVelocity;
|
|
58
63
|
bounced = true;
|
|
@@ -64,7 +69,7 @@ export function bounceVertical(data) {
|
|
|
64
69
|
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") {
|
|
65
70
|
data.particle.position.y = data.canvasSize.height - minPos;
|
|
66
71
|
}
|
|
67
|
-
else if (data.bounds.top <=
|
|
72
|
+
else if (data.bounds.top <= boundsMin && data.direction === "top") {
|
|
68
73
|
data.particle.position.y = minPos;
|
|
69
74
|
}
|
|
70
75
|
if (data.outMode === "split") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/updater-out-modes",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "tsParticles particles out modes updater",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"./package.json": "./package.json"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@tsparticles/engine": "^3.0
|
|
90
|
+
"@tsparticles/engine": "^3.1.0"
|
|
91
91
|
},
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"access": "public"
|
package/report.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8"/>
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
6
|
-
<title>@tsparticles/updater-out-modes [
|
|
6
|
+
<title>@tsparticles/updater-out-modes [13 Jan 2024 at 23:08]</title>
|
|
7
7
|
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
|
|
8
8
|
|
|
9
9
|
<script>
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
<body>
|
|
32
32
|
<div id="app"></div>
|
|
33
33
|
<script>
|
|
34
|
-
window.chartData = [{"label":"tsparticles.updater.out-modes.js","isAsset":true,"statSize":
|
|
34
|
+
window.chartData = [{"label":"tsparticles.updater.out-modes.js","isAsset":true,"statSize":13442,"parsedSize":17636,"gzipSize":3492,"groups":[{"label":"dist/browser","path":"./dist/browser","statSize":13400,"groups":[{"id":421,"label":"index.js + 6 modules (concatenated)","path":"./dist/browser/index.js + 6 modules (concatenated)","statSize":13400,"parsedSize":17636,"gzipSize":3492,"concatenated":true,"groups":[{"label":"dist/browser","path":"./dist/browser/index.js + 6 modules (concatenated)/dist/browser","statSize":13400,"groups":[{"id":null,"label":"index.js","path":"./dist/browser/index.js + 6 modules (concatenated)/dist/browser/index.js","statSize":235,"parsedSize":309,"gzipSize":61,"inaccurateSizes":true},{"id":null,"label":"OutOfCanvasUpdater.js","path":"./dist/browser/index.js + 6 modules (concatenated)/dist/browser/OutOfCanvasUpdater.js","statSize":1149,"parsedSize":1512,"gzipSize":299,"inaccurateSizes":true},{"id":null,"label":"BounceOutMode.js","path":"./dist/browser/index.js + 6 modules (concatenated)/dist/browser/BounceOutMode.js","statSize":1230,"parsedSize":1618,"gzipSize":320,"inaccurateSizes":true},{"id":null,"label":"DestroyOutMode.js","path":"./dist/browser/index.js + 6 modules (concatenated)/dist/browser/DestroyOutMode.js","statSize":1209,"parsedSize":1591,"gzipSize":315,"inaccurateSizes":true},{"id":null,"label":"OutOutMode.js","path":"./dist/browser/index.js + 6 modules (concatenated)/dist/browser/OutOutMode.js","statSize":5149,"parsedSize":6776,"gzipSize":1341,"inaccurateSizes":true},{"id":null,"label":"NoneOutMode.js","path":"./dist/browser/index.js + 6 modules (concatenated)/dist/browser/NoneOutMode.js","statSize":1565,"parsedSize":2059,"gzipSize":407,"inaccurateSizes":true},{"id":null,"label":"Utils.js","path":"./dist/browser/index.js + 6 modules (concatenated)/dist/browser/Utils.js","statSize":2863,"parsedSize":3768,"gzipSize":746,"inaccurateSizes":true}],"parsedSize":17636,"gzipSize":3492,"inaccurateSizes":true}]}],"parsedSize":17636,"gzipSize":3492},{"label":"engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","statSize":42,"groups":[{"id":533,"label":"engine\",\"root\":\"window\"}","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles/engine\",\"root\":\"window\"}","statSize":42}],"parsedSize":0,"gzipSize":0}],"isInitialByEntrypoint":{"tsparticles.updater.out-modes":true}}];
|
|
35
35
|
window.entrypoints = ["tsparticles.updater.out-modes","tsparticles.updater.out-modes.min"];
|
|
36
36
|
window.defaultSizes = "parsed";
|
|
37
37
|
</script>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Demo / Generator : https://particles.js.org/
|
|
5
5
|
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
6
|
* How to use? : Check the GitHub README
|
|
7
|
-
* v3.0
|
|
7
|
+
* v3.1.0
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -98,18 +98,20 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
98
98
|
var engine_root_window_ = __webpack_require__(533);
|
|
99
99
|
;// CONCATENATED MODULE: ./dist/browser/Utils.js
|
|
100
100
|
|
|
101
|
+
const minVelocity = 0,
|
|
102
|
+
boundsMin = 0;
|
|
101
103
|
function bounceHorizontal(data) {
|
|
102
104
|
if (data.outMode !== "bounce" && data.outMode !== "bounce-horizontal" && data.outMode !== "bounceHorizontal" && data.outMode !== "split" || data.direction !== "left" && data.direction !== "right") {
|
|
103
105
|
return;
|
|
104
106
|
}
|
|
105
|
-
if (data.bounds.right <
|
|
107
|
+
if (data.bounds.right < boundsMin && data.direction === "left") {
|
|
106
108
|
data.particle.position.x = data.size + data.offset.x;
|
|
107
109
|
} else if (data.bounds.left > data.canvasSize.width && data.direction === "right") {
|
|
108
110
|
data.particle.position.x = data.canvasSize.width - data.size - data.offset.x;
|
|
109
111
|
}
|
|
110
112
|
const velocity = data.particle.velocity.x;
|
|
111
113
|
let bounced = false;
|
|
112
|
-
if (data.direction === "right" && data.bounds.right >= data.canvasSize.width && velocity >
|
|
114
|
+
if (data.direction === "right" && data.bounds.right >= data.canvasSize.width && velocity > minVelocity || data.direction === "left" && data.bounds.left <= boundsMin && velocity < minVelocity) {
|
|
113
115
|
const newVelocity = (0,engine_root_window_.getRangeValue)(data.particle.options.bounce.horizontal.value);
|
|
114
116
|
data.particle.velocity.x *= -newVelocity;
|
|
115
117
|
bounced = true;
|
|
@@ -120,7 +122,7 @@ function bounceHorizontal(data) {
|
|
|
120
122
|
const minPos = data.offset.x + data.size;
|
|
121
123
|
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") {
|
|
122
124
|
data.particle.position.x = data.canvasSize.width - minPos;
|
|
123
|
-
} else if (data.bounds.left <=
|
|
125
|
+
} else if (data.bounds.left <= boundsMin && data.direction === "left") {
|
|
124
126
|
data.particle.position.x = minPos;
|
|
125
127
|
}
|
|
126
128
|
if (data.outMode === "split") {
|
|
@@ -131,14 +133,14 @@ function bounceVertical(data) {
|
|
|
131
133
|
if (data.outMode !== "bounce" && data.outMode !== "bounce-vertical" && data.outMode !== "bounceVertical" && data.outMode !== "split" || data.direction !== "bottom" && data.direction !== "top") {
|
|
132
134
|
return;
|
|
133
135
|
}
|
|
134
|
-
if (data.bounds.bottom <
|
|
136
|
+
if (data.bounds.bottom < boundsMin && data.direction === "top") {
|
|
135
137
|
data.particle.position.y = data.size + data.offset.y;
|
|
136
138
|
} else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") {
|
|
137
139
|
data.particle.position.y = data.canvasSize.height - data.size - data.offset.y;
|
|
138
140
|
}
|
|
139
141
|
const velocity = data.particle.velocity.y;
|
|
140
142
|
let bounced = false;
|
|
141
|
-
if (data.direction === "bottom" && data.bounds.bottom >= data.canvasSize.height && velocity >
|
|
143
|
+
if (data.direction === "bottom" && data.bounds.bottom >= data.canvasSize.height && velocity > minVelocity || data.direction === "top" && data.bounds.top <= boundsMin && velocity < minVelocity) {
|
|
142
144
|
const newVelocity = (0,engine_root_window_.getRangeValue)(data.particle.options.bounce.vertical.value);
|
|
143
145
|
data.particle.velocity.y *= -newVelocity;
|
|
144
146
|
bounced = true;
|
|
@@ -149,7 +151,7 @@ function bounceVertical(data) {
|
|
|
149
151
|
const minPos = data.offset.y + data.size;
|
|
150
152
|
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") {
|
|
151
153
|
data.particle.position.y = data.canvasSize.height - minPos;
|
|
152
|
-
} else if (data.bounds.top <=
|
|
154
|
+
} else if (data.bounds.top <= boundsMin && data.direction === "top") {
|
|
153
155
|
data.particle.position.y = minPos;
|
|
154
156
|
}
|
|
155
157
|
if (data.outMode === "split") {
|
|
@@ -208,6 +210,7 @@ class BounceOutMode {
|
|
|
208
210
|
}
|
|
209
211
|
;// CONCATENATED MODULE: ./dist/browser/DestroyOutMode.js
|
|
210
212
|
|
|
213
|
+
const DestroyOutMode_minVelocity = 0;
|
|
211
214
|
class DestroyOutMode {
|
|
212
215
|
constructor(container) {
|
|
213
216
|
this.container = container;
|
|
@@ -235,7 +238,7 @@ class DestroyOutMode {
|
|
|
235
238
|
x: vx,
|
|
236
239
|
y: vy
|
|
237
240
|
} = particle.velocity;
|
|
238
|
-
if (vx <
|
|
241
|
+
if (vx < DestroyOutMode_minVelocity && dx > particle.moveCenter.radius || vy < DestroyOutMode_minVelocity && dy > particle.moveCenter.radius || vx >= DestroyOutMode_minVelocity && dx < -particle.moveCenter.radius || vy >= DestroyOutMode_minVelocity && dy < -particle.moveCenter.radius) {
|
|
239
242
|
return;
|
|
240
243
|
}
|
|
241
244
|
break;
|
|
@@ -246,6 +249,7 @@ class DestroyOutMode {
|
|
|
246
249
|
}
|
|
247
250
|
;// CONCATENATED MODULE: ./dist/browser/NoneOutMode.js
|
|
248
251
|
|
|
252
|
+
const NoneOutMode_minVelocity = 0;
|
|
249
253
|
class NoneOutMode {
|
|
250
254
|
constructor(container) {
|
|
251
255
|
this.container = container;
|
|
@@ -255,7 +259,7 @@ class NoneOutMode {
|
|
|
255
259
|
if (!this.modes.includes(outMode)) {
|
|
256
260
|
return;
|
|
257
261
|
}
|
|
258
|
-
if (particle.options.move.distance.horizontal && (direction === "left" || direction === "right")
|
|
262
|
+
if ((particle.options.move.distance.horizontal && (direction === "left" || direction === "right")) ?? (particle.options.move.distance.vertical && (direction === "top" || direction === "bottom"))) {
|
|
259
263
|
return;
|
|
260
264
|
}
|
|
261
265
|
const gravityOptions = particle.options.move.gravity,
|
|
@@ -263,7 +267,7 @@ class NoneOutMode {
|
|
|
263
267
|
const canvasSize = container.canvas.size;
|
|
264
268
|
const pRadius = particle.getRadius();
|
|
265
269
|
if (!gravityOptions.enable) {
|
|
266
|
-
if (particle.velocity.y >
|
|
270
|
+
if (particle.velocity.y > NoneOutMode_minVelocity && particle.position.y <= canvasSize.height + pRadius || particle.velocity.y < NoneOutMode_minVelocity && particle.position.y >= -pRadius || particle.velocity.x > NoneOutMode_minVelocity && particle.position.x <= canvasSize.width + pRadius || particle.velocity.x < NoneOutMode_minVelocity && particle.position.x >= -pRadius) {
|
|
267
271
|
return;
|
|
268
272
|
}
|
|
269
273
|
if (!(0,engine_root_window_.isPointInside)(particle.position, container.canvas.size, engine_root_window_.Vector.origin, pRadius, direction)) {
|
|
@@ -279,6 +283,8 @@ class NoneOutMode {
|
|
|
279
283
|
}
|
|
280
284
|
;// CONCATENATED MODULE: ./dist/browser/OutOutMode.js
|
|
281
285
|
|
|
286
|
+
const OutOutMode_minVelocity = 0,
|
|
287
|
+
minDistance = 0;
|
|
282
288
|
class OutOutMode {
|
|
283
289
|
constructor(container) {
|
|
284
290
|
this.container = container;
|
|
@@ -304,7 +310,7 @@ class OutOutMode {
|
|
|
304
310
|
dx,
|
|
305
311
|
dy
|
|
306
312
|
} = (0,engine_root_window_.getDistances)(particle.position, circVec);
|
|
307
|
-
if (vx <=
|
|
313
|
+
if (vx <= OutOutMode_minVelocity && dx >= minDistance || vy <= OutOutMode_minVelocity && dy >= minDistance || vx >= OutOutMode_minVelocity && dx <= minDistance || vy >= OutOutMode_minVelocity && dy <= minDistance) {
|
|
308
314
|
return;
|
|
309
315
|
}
|
|
310
316
|
particle.position.x = Math.floor((0,engine_root_window_.randomInRange)({
|
|
@@ -406,12 +412,12 @@ class OutOutMode {
|
|
|
406
412
|
|
|
407
413
|
class OutOfCanvasUpdater {
|
|
408
414
|
constructor(container) {
|
|
409
|
-
this.container = container;
|
|
410
415
|
this._updateOutMode = (particle, delta, outMode, direction) => {
|
|
411
416
|
for (const updater of this.updaters) {
|
|
412
417
|
updater.update(particle, direction, delta, outMode);
|
|
413
418
|
}
|
|
414
419
|
};
|
|
420
|
+
this.container = container;
|
|
415
421
|
this.updaters = [new BounceOutMode(container), new DestroyOutMode(container), new OutOutMode(container), new NoneOutMode(container)];
|
|
416
422
|
}
|
|
417
423
|
init() {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.updater.out-modes.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var o="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var i in o)("object"==typeof exports?exports:t)[i]=o[i]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},o={};function i(t){var n=o[t];if(void 0!==n)return n.exports;var s=o[t]={exports:{}};return e[t](s,s.exports,i),s.exports}i.d=(t,e)=>{for(var o in e)i.o(e,o)&&!i.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),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 e{constructor(t){this.container=t,this.modes=["bounce","bounce-vertical","bounce-horizontal","bounceVertical","bounceHorizontal","split"]}update(e,o,i,n){if(!this.modes.includes(n))return;const s=this.container;let r=!1;for(const[,t]of s.plugins)if(void 0!==t.particleBounce&&(r=t.particleBounce(e,i,o)),r)break;if(r)return;const a=e.getPosition(),c=e.offset,d=e.getRadius(),u=(0,t.calculateBounds)(a,d),p=s.canvas.size;!function(e){if("bounce"!==e.outMode&&"bounce-horizontal"!==e.outMode&&"bounceHorizontal"!==e.outMode&&"split"!==e.outMode||"left"!==e.direction&&"right"!==e.direction)return;e.bounds.right<0&&"left"===e.direction?e.particle.position.x=e.size+e.offset.x:e.bounds.left>e.canvasSize.width&&"right"===e.direction&&(e.particle.position.x=e.canvasSize.width-e.size-e.offset.x);const o=e.particle.velocity.x;let i=!1;if("right"===e.direction&&e.bounds.right>=e.canvasSize.width&&o>0||"left"===e.direction&&e.bounds.left<=0&&o<0){const o=(0,t.getRangeValue)(e.particle.options.bounce.horizontal.value);e.particle.velocity.x*=-o,i=!0}if(!i)return;const n=e.offset.x+e.size;e.bounds.right>=e.canvasSize.width&&"right"===e.direction?e.particle.position.x=e.canvasSize.width-n:e.bounds.left<=0&&"left"===e.direction&&(e.particle.position.x=n),"split"===e.outMode&&e.particle.destroy()}({particle:e,outMode:n,direction:o,bounds:u,canvasSize:p,offset:c,size:d}),function(e){if("bounce"!==e.outMode&&"bounce-vertical"!==e.outMode&&"bounceVertical"!==e.outMode&&"split"!==e.outMode||"bottom"!==e.direction&&"top"!==e.direction)return;e.bounds.bottom<0&&"top"===e.direction?e.particle.position.y=e.size+e.offset.y:e.bounds.top>e.canvasSize.height&&"bottom"===e.direction&&(e.particle.position.y=e.canvasSize.height-e.size-e.offset.y);const o=e.particle.velocity.y;let i=!1;if("bottom"===e.direction&&e.bounds.bottom>=e.canvasSize.height&&o>0||"top"===e.direction&&e.bounds.top<=0&&o<0){const o=(0,t.getRangeValue)(e.particle.options.bounce.vertical.value);e.particle.velocity.y*=-o,i=!0}if(!i)return;const n=e.offset.y+e.size;e.bounds.bottom>=e.canvasSize.height&&"bottom"===e.direction?e.particle.position.y=e.canvasSize.height-n:e.bounds.top<=0&&"top"===e.direction&&(e.particle.position.y=n),"split"===e.outMode&&e.particle.destroy()}({particle:e,outMode:n,direction:o,bounds:u,canvasSize:p,offset:c,size:d})}}class o{constructor(t){this.container=t,this.modes=["destroy"]}update(e,o,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(e.outType){case"normal":case"outside":if((0,t.isPointInside)(e.position,s.canvas.size,t.Vector.origin,e.getRadius(),o))return;break;case"inside":{const{dx:o,dy:i}=(0,t.getDistances)(e.position,e.moveCenter),{x:n,y:s}=e.velocity;if(n<0&&o>e.moveCenter.radius||s<0&&i>e.moveCenter.radius||n>=0&&o<-e.moveCenter.radius||s>=0&&i<-e.moveCenter.radius)return;break}}s.particles.remove(e,void 0,!0)}}class s{constructor(t){this.container=t,this.modes=["none"]}update(e,o,i,n){if(!this.modes.includes(n))return;if(e.options.move.distance.horizontal&&("left"===o||"right"===o)
|
|
2
|
+
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var o="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var i in o)("object"==typeof exports?exports:t)[i]=o[i]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},o={};function i(t){var n=o[t];if(void 0!==n)return n.exports;var s=o[t]={exports:{}};return e[t](s,s.exports,i),s.exports}i.d=(t,e)=>{for(var o in e)i.o(e,o)&&!i.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),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 e{constructor(t){this.container=t,this.modes=["bounce","bounce-vertical","bounce-horizontal","bounceVertical","bounceHorizontal","split"]}update(e,o,i,n){if(!this.modes.includes(n))return;const s=this.container;let r=!1;for(const[,t]of s.plugins)if(void 0!==t.particleBounce&&(r=t.particleBounce(e,i,o)),r)break;if(r)return;const a=e.getPosition(),c=e.offset,d=e.getRadius(),u=(0,t.calculateBounds)(a,d),p=s.canvas.size;!function(e){if("bounce"!==e.outMode&&"bounce-horizontal"!==e.outMode&&"bounceHorizontal"!==e.outMode&&"split"!==e.outMode||"left"!==e.direction&&"right"!==e.direction)return;e.bounds.right<0&&"left"===e.direction?e.particle.position.x=e.size+e.offset.x:e.bounds.left>e.canvasSize.width&&"right"===e.direction&&(e.particle.position.x=e.canvasSize.width-e.size-e.offset.x);const o=e.particle.velocity.x;let i=!1;if("right"===e.direction&&e.bounds.right>=e.canvasSize.width&&o>0||"left"===e.direction&&e.bounds.left<=0&&o<0){const o=(0,t.getRangeValue)(e.particle.options.bounce.horizontal.value);e.particle.velocity.x*=-o,i=!0}if(!i)return;const n=e.offset.x+e.size;e.bounds.right>=e.canvasSize.width&&"right"===e.direction?e.particle.position.x=e.canvasSize.width-n:e.bounds.left<=0&&"left"===e.direction&&(e.particle.position.x=n),"split"===e.outMode&&e.particle.destroy()}({particle:e,outMode:n,direction:o,bounds:u,canvasSize:p,offset:c,size:d}),function(e){if("bounce"!==e.outMode&&"bounce-vertical"!==e.outMode&&"bounceVertical"!==e.outMode&&"split"!==e.outMode||"bottom"!==e.direction&&"top"!==e.direction)return;e.bounds.bottom<0&&"top"===e.direction?e.particle.position.y=e.size+e.offset.y:e.bounds.top>e.canvasSize.height&&"bottom"===e.direction&&(e.particle.position.y=e.canvasSize.height-e.size-e.offset.y);const o=e.particle.velocity.y;let i=!1;if("bottom"===e.direction&&e.bounds.bottom>=e.canvasSize.height&&o>0||"top"===e.direction&&e.bounds.top<=0&&o<0){const o=(0,t.getRangeValue)(e.particle.options.bounce.vertical.value);e.particle.velocity.y*=-o,i=!0}if(!i)return;const n=e.offset.y+e.size;e.bounds.bottom>=e.canvasSize.height&&"bottom"===e.direction?e.particle.position.y=e.canvasSize.height-n:e.bounds.top<=0&&"top"===e.direction&&(e.particle.position.y=n),"split"===e.outMode&&e.particle.destroy()}({particle:e,outMode:n,direction:o,bounds:u,canvasSize:p,offset:c,size:d})}}class o{constructor(t){this.container=t,this.modes=["destroy"]}update(e,o,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(e.outType){case"normal":case"outside":if((0,t.isPointInside)(e.position,s.canvas.size,t.Vector.origin,e.getRadius(),o))return;break;case"inside":{const{dx:o,dy:i}=(0,t.getDistances)(e.position,e.moveCenter),{x:n,y:s}=e.velocity;if(n<0&&o>e.moveCenter.radius||s<0&&i>e.moveCenter.radius||n>=0&&o<-e.moveCenter.radius||s>=0&&i<-e.moveCenter.radius)return;break}}s.particles.remove(e,void 0,!0)}}class s{constructor(t){this.container=t,this.modes=["none"]}update(e,o,i,n){if(!this.modes.includes(n))return;if((e.options.move.distance.horizontal&&("left"===o||"right"===o))??(e.options.move.distance.vertical&&("top"===o||"bottom"===o)))return;const s=e.options.move.gravity,r=this.container,a=r.canvas.size,c=e.getRadius();if(s.enable){const t=e.position;(!s.inverse&&t.y>a.height+c&&"bottom"===o||s.inverse&&t.y<-c&&"top"===o)&&r.particles.remove(e)}else{if(e.velocity.y>0&&e.position.y<=a.height+c||e.velocity.y<0&&e.position.y>=-c||e.velocity.x>0&&e.position.x<=a.width+c||e.velocity.x<0&&e.position.x>=-c)return;(0,t.isPointInside)(e.position,r.canvas.size,t.Vector.origin,c,o)||r.particles.remove(e)}}}class r{constructor(t){this.container=t,this.modes=["out"]}update(e,o,i,n){if(!this.modes.includes(n))return;const s=this.container;switch(e.outType){case"inside":{const{x:o,y:i}=e.velocity,n=t.Vector.origin;n.length=e.moveCenter.radius,n.angle=e.velocity.angle+Math.PI,n.addTo(t.Vector.create(e.moveCenter));const{dx:r,dy:a}=(0,t.getDistances)(e.position,n);if(o<=0&&r>=0||i<=0&&a>=0||o>=0&&r<=0||i>=0&&a<=0)return;e.position.x=Math.floor((0,t.randomInRange)({min:0,max:s.canvas.size.width})),e.position.y=Math.floor((0,t.randomInRange)({min:0,max:s.canvas.size.height}));const{dx:c,dy:d}=(0,t.getDistances)(e.position,e.moveCenter);e.direction=Math.atan2(-d,-c),e.velocity.angle=e.direction;break}default:if((0,t.isPointInside)(e.position,s.canvas.size,t.Vector.origin,e.getRadius(),o))return;switch(e.outType){case"outside":{e.position.x=Math.floor((0,t.randomInRange)({min:-e.moveCenter.radius,max:e.moveCenter.radius}))+e.moveCenter.x,e.position.y=Math.floor((0,t.randomInRange)({min:-e.moveCenter.radius,max:e.moveCenter.radius}))+e.moveCenter.y;const{dx:o,dy:i}=(0,t.getDistances)(e.position,e.moveCenter);e.moveCenter.radius&&(e.direction=Math.atan2(i,o),e.velocity.angle=e.direction);break}case"normal":{const i=e.options.move.warp,n=s.canvas.size,r={bottom:n.height+e.getRadius()+e.offset.y,left:-e.getRadius()-e.offset.x,right:n.width+e.getRadius()+e.offset.x,top:-e.getRadius()-e.offset.y},a=e.getRadius(),c=(0,t.calculateBounds)(e.position,a);"right"===o&&c.left>n.width+e.offset.x?(e.position.x=r.left,e.initialPosition.x=e.position.x,i||(e.position.y=(0,t.getRandom)()*n.height,e.initialPosition.y=e.position.y)):"left"===o&&c.right<-e.offset.x&&(e.position.x=r.right,e.initialPosition.x=e.position.x,i||(e.position.y=(0,t.getRandom)()*n.height,e.initialPosition.y=e.position.y)),"bottom"===o&&c.top>n.height+e.offset.y?(i||(e.position.x=(0,t.getRandom)()*n.width,e.initialPosition.x=e.position.x),e.position.y=r.top,e.initialPosition.y=e.position.y):"top"===o&&c.bottom<-e.offset.y&&(i||(e.position.x=(0,t.getRandom)()*n.width,e.initialPosition.x=e.position.x),e.position.y=r.bottom,e.initialPosition.y=e.position.y);break}}}}}class a{constructor(t){this._updateOutMode=(t,e,o,i)=>{for(const n of this.updaters)n.update(t,i,e,o)},this.container=t,this.updaters=[new e(t),new o(t),new r(t),new s(t)]}init(){}isEnabled(t){return!t.destroyed&&!t.spawning}update(t,e){const o=t.options.move.outModes;this._updateOutMode(t,e,o.bottom??o.default,"bottom"),this._updateOutMode(t,e,o.left??o.default,"left"),this._updateOutMode(t,e,o.right??o.default,"right"),this._updateOutMode(t,e,o.top??o.default,"top")}}async function c(t,e=!0){await t.addParticleUpdater("outModes",(t=>new a(t)),e)}})(),n})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Out Modes Updater v3.0
|
|
1
|
+
/*! tsParticles Out Modes Updater v3.1.0 by Matteo Bruni */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Container, type IDelta, type IParticleUpdater, type Particle } from "@tsparticles/engine";
|
|
2
2
|
import type { IOutModeManager } from "./IOutModeManager.js";
|
|
3
3
|
export declare class OutOfCanvasUpdater implements IParticleUpdater {
|
|
4
|
-
private readonly container;
|
|
5
4
|
updaters: IOutModeManager[];
|
|
5
|
+
private readonly container;
|
|
6
6
|
constructor(container: Container);
|
|
7
7
|
init(): void;
|
|
8
8
|
isEnabled(particle: Particle): boolean;
|
package/umd/DestroyOutMode.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.DestroyOutMode = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const minVelocity = 0;
|
|
14
15
|
class DestroyOutMode {
|
|
15
16
|
constructor(container) {
|
|
16
17
|
this.container = container;
|
|
@@ -31,10 +32,10 @@
|
|
|
31
32
|
case "inside": {
|
|
32
33
|
const { dx, dy } = (0, engine_1.getDistances)(particle.position, particle.moveCenter);
|
|
33
34
|
const { x: vx, y: vy } = particle.velocity;
|
|
34
|
-
if ((vx <
|
|
35
|
-
(vy <
|
|
36
|
-
(vx >=
|
|
37
|
-
(vy >=
|
|
35
|
+
if ((vx < minVelocity && dx > particle.moveCenter.radius) ||
|
|
36
|
+
(vy < minVelocity && dy > particle.moveCenter.radius) ||
|
|
37
|
+
(vx >= minVelocity && dx < -particle.moveCenter.radius) ||
|
|
38
|
+
(vy >= minVelocity && dy < -particle.moveCenter.radius)) {
|
|
38
39
|
return;
|
|
39
40
|
}
|
|
40
41
|
break;
|
package/umd/NoneOutMode.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.NoneOutMode = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const minVelocity = 0;
|
|
14
15
|
class NoneOutMode {
|
|
15
16
|
constructor(container) {
|
|
16
17
|
this.container = container;
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
24
|
if ((particle.options.move.distance.horizontal &&
|
|
24
|
-
(direction === "left" || direction === "right"))
|
|
25
|
+
(direction === "left" || direction === "right")) ??
|
|
25
26
|
(particle.options.move.distance.vertical &&
|
|
26
27
|
(direction === "top" || direction === "bottom"))) {
|
|
27
28
|
return;
|
|
@@ -30,10 +31,10 @@
|
|
|
30
31
|
const canvasSize = container.canvas.size;
|
|
31
32
|
const pRadius = particle.getRadius();
|
|
32
33
|
if (!gravityOptions.enable) {
|
|
33
|
-
if ((particle.velocity.y >
|
|
34
|
-
(particle.velocity.y <
|
|
35
|
-
(particle.velocity.x >
|
|
36
|
-
(particle.velocity.x <
|
|
34
|
+
if ((particle.velocity.y > minVelocity && particle.position.y <= canvasSize.height + pRadius) ||
|
|
35
|
+
(particle.velocity.y < minVelocity && particle.position.y >= -pRadius) ||
|
|
36
|
+
(particle.velocity.x > minVelocity && particle.position.x <= canvasSize.width + pRadius) ||
|
|
37
|
+
(particle.velocity.x < minVelocity && particle.position.x >= -pRadius)) {
|
|
37
38
|
return;
|
|
38
39
|
}
|
|
39
40
|
if (!(0, engine_1.isPointInside)(particle.position, container.canvas.size, engine_1.Vector.origin, pRadius, direction)) {
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
const OutOutMode_js_1 = require("./OutOutMode.js");
|
|
17
17
|
class OutOfCanvasUpdater {
|
|
18
18
|
constructor(container) {
|
|
19
|
-
this.container = container;
|
|
20
19
|
this._updateOutMode = (particle, delta, outMode, direction) => {
|
|
21
20
|
for (const updater of this.updaters) {
|
|
22
21
|
updater.update(particle, direction, delta, outMode);
|
|
23
22
|
}
|
|
24
23
|
};
|
|
24
|
+
this.container = container;
|
|
25
25
|
this.updaters = [
|
|
26
26
|
new BounceOutMode_js_1.BounceOutMode(container),
|
|
27
27
|
new DestroyOutMode_js_1.DestroyOutMode(container),
|
package/umd/OutOutMode.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.OutOutMode = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const minVelocity = 0, minDistance = 0;
|
|
14
15
|
class OutOutMode {
|
|
15
16
|
constructor(container) {
|
|
16
17
|
this.container = container;
|
|
@@ -29,7 +30,10 @@
|
|
|
29
30
|
circVec.angle = particle.velocity.angle + Math.PI;
|
|
30
31
|
circVec.addTo(engine_1.Vector.create(particle.moveCenter));
|
|
31
32
|
const { dx, dy } = (0, engine_1.getDistances)(particle.position, circVec);
|
|
32
|
-
if ((vx <=
|
|
33
|
+
if ((vx <= minVelocity && dx >= minDistance) ||
|
|
34
|
+
(vy <= minVelocity && dy >= minDistance) ||
|
|
35
|
+
(vx >= minVelocity && dx <= minDistance) ||
|
|
36
|
+
(vy >= minVelocity && dy <= minDistance)) {
|
|
33
37
|
return;
|
|
34
38
|
}
|
|
35
39
|
particle.position.x = Math.floor((0, engine_1.randomInRange)({
|
package/umd/Utils.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.bounceVertical = exports.bounceHorizontal = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const minVelocity = 0, boundsMin = 0;
|
|
14
15
|
function bounceHorizontal(data) {
|
|
15
16
|
if ((data.outMode !== "bounce" &&
|
|
16
17
|
data.outMode !== "bounce-horizontal" &&
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
(data.direction !== "left" && data.direction !== "right")) {
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
22
|
-
if (data.bounds.right <
|
|
23
|
+
if (data.bounds.right < boundsMin && data.direction === "left") {
|
|
23
24
|
data.particle.position.x = data.size + data.offset.x;
|
|
24
25
|
}
|
|
25
26
|
else if (data.bounds.left > data.canvasSize.width && data.direction === "right") {
|
|
@@ -27,8 +28,10 @@
|
|
|
27
28
|
}
|
|
28
29
|
const velocity = data.particle.velocity.x;
|
|
29
30
|
let bounced = false;
|
|
30
|
-
if ((data.direction === "right" &&
|
|
31
|
-
|
|
31
|
+
if ((data.direction === "right" &&
|
|
32
|
+
data.bounds.right >= data.canvasSize.width &&
|
|
33
|
+
velocity > minVelocity) ||
|
|
34
|
+
(data.direction === "left" && data.bounds.left <= boundsMin && velocity < minVelocity)) {
|
|
32
35
|
const newVelocity = (0, engine_1.getRangeValue)(data.particle.options.bounce.horizontal.value);
|
|
33
36
|
data.particle.velocity.x *= -newVelocity;
|
|
34
37
|
bounced = true;
|
|
@@ -40,7 +43,7 @@
|
|
|
40
43
|
if (data.bounds.right >= data.canvasSize.width && data.direction === "right") {
|
|
41
44
|
data.particle.position.x = data.canvasSize.width - minPos;
|
|
42
45
|
}
|
|
43
|
-
else if (data.bounds.left <=
|
|
46
|
+
else if (data.bounds.left <= boundsMin && data.direction === "left") {
|
|
44
47
|
data.particle.position.x = minPos;
|
|
45
48
|
}
|
|
46
49
|
if (data.outMode === "split") {
|
|
@@ -56,7 +59,7 @@
|
|
|
56
59
|
(data.direction !== "bottom" && data.direction !== "top")) {
|
|
57
60
|
return;
|
|
58
61
|
}
|
|
59
|
-
if (data.bounds.bottom <
|
|
62
|
+
if (data.bounds.bottom < boundsMin && data.direction === "top") {
|
|
60
63
|
data.particle.position.y = data.size + data.offset.y;
|
|
61
64
|
}
|
|
62
65
|
else if (data.bounds.top > data.canvasSize.height && data.direction === "bottom") {
|
|
@@ -64,8 +67,10 @@
|
|
|
64
67
|
}
|
|
65
68
|
const velocity = data.particle.velocity.y;
|
|
66
69
|
let bounced = false;
|
|
67
|
-
if ((data.direction === "bottom" &&
|
|
68
|
-
|
|
70
|
+
if ((data.direction === "bottom" &&
|
|
71
|
+
data.bounds.bottom >= data.canvasSize.height &&
|
|
72
|
+
velocity > minVelocity) ||
|
|
73
|
+
(data.direction === "top" && data.bounds.top <= boundsMin && velocity < minVelocity)) {
|
|
69
74
|
const newVelocity = (0, engine_1.getRangeValue)(data.particle.options.bounce.vertical.value);
|
|
70
75
|
data.particle.velocity.y *= -newVelocity;
|
|
71
76
|
bounced = true;
|
|
@@ -77,7 +82,7 @@
|
|
|
77
82
|
if (data.bounds.bottom >= data.canvasSize.height && data.direction === "bottom") {
|
|
78
83
|
data.particle.position.y = data.canvasSize.height - minPos;
|
|
79
84
|
}
|
|
80
|
-
else if (data.bounds.top <=
|
|
85
|
+
else if (data.bounds.top <= boundsMin && data.direction === "top") {
|
|
81
86
|
data.particle.position.y = minPos;
|
|
82
87
|
}
|
|
83
88
|
if (data.outMode === "split") {
|