tsparticles 1.37.2 → 1.37.6
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/Plugins/Absorbers/AbsorberInstance.d.ts +2 -1
- package/Plugins/Absorbers/AbsorberInstance.js +21 -9
- package/Plugins/Absorbers/Options/Classes/AbsorberSize.d.ts +2 -1
- package/Plugins/Absorbers/Options/Classes/AbsorberSize.js +6 -4
- package/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.d.ts +9 -0
- package/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.js +21 -0
- package/Plugins/Absorbers/Options/Interfaces/IAbsorberSize.d.ts +3 -2
- package/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.d.ts +4 -0
- package/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.js +2 -0
- package/README.md +68 -0
- package/Utils/EventListeners.d.ts +1 -0
- package/Utils/EventListeners.js +13 -2
- package/Utils/Utils.js +4 -7
- package/browser/Plugins/Absorbers/AbsorberInstance.d.ts +2 -1
- package/browser/Plugins/Absorbers/AbsorberInstance.js +21 -9
- package/browser/Plugins/Absorbers/Options/Classes/AbsorberSize.d.ts +2 -1
- package/browser/Plugins/Absorbers/Options/Classes/AbsorberSize.js +6 -4
- package/browser/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.d.ts +9 -0
- package/browser/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.js +17 -0
- package/browser/Plugins/Absorbers/Options/Interfaces/IAbsorberSize.d.ts +3 -2
- package/browser/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.d.ts +4 -0
- package/browser/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.js +1 -0
- package/browser/Utils/EventListeners.d.ts +1 -0
- package/browser/Utils/EventListeners.js +14 -3
- package/browser/Utils/Utils.js +5 -8
- package/esm/Plugins/Absorbers/AbsorberInstance.d.ts +2 -1
- package/esm/Plugins/Absorbers/AbsorberInstance.js +21 -9
- package/esm/Plugins/Absorbers/Options/Classes/AbsorberSize.d.ts +2 -1
- package/esm/Plugins/Absorbers/Options/Classes/AbsorberSize.js +6 -4
- package/esm/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.d.ts +9 -0
- package/esm/Plugins/Absorbers/Options/Classes/AbsorberSizeLimit.js +17 -0
- package/esm/Plugins/Absorbers/Options/Interfaces/IAbsorberSize.d.ts +3 -2
- package/esm/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.d.ts +4 -0
- package/esm/Plugins/Absorbers/Options/Interfaces/IAbsorberSizeLimit.js +1 -0
- package/esm/Utils/EventListeners.d.ts +1 -0
- package/esm/Utils/EventListeners.js +14 -3
- package/esm/Utils/Utils.js +5 -8
- package/package.json +1 -1
- package/report.html +2 -2
- package/report.slim.html +2 -2
- package/scripts/install.js +14 -3
- package/tsparticles.js +55 -23
- package/tsparticles.min.js +2 -2
- package/tsparticles.slim.js +15 -9
- package/tsparticles.slim.min.js +2 -2
package/scripts/install.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const reactParticlesJsFoundError = "react-particles-js-found";
|
|
3
|
+
|
|
1
4
|
try {
|
|
2
5
|
console.log("Thank you for installing tsParticles.");
|
|
3
6
|
console.log("Remember to checkout the official website https://particles.js.org to explore some samples.");
|
|
@@ -5,8 +8,6 @@ try {
|
|
|
5
8
|
console.log("If you need documentation you can find it here: https://particles.js.org");
|
|
6
9
|
console.log("Remember to leave a star on the tsParticles repository if you like the project and want to support it: https://github.com/matteobruni/tsparticles");
|
|
7
10
|
|
|
8
|
-
const path = require('path');
|
|
9
|
-
|
|
10
11
|
const pkgSettings = require(path.join(process.env.INIT_CWD, "package.json"));
|
|
11
12
|
|
|
12
13
|
if (!pkgSettings) {
|
|
@@ -19,6 +20,12 @@ try {
|
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
if (dependencies["react-particles-js"]) {
|
|
24
|
+
console.error("\x1b[31m%s\x1b[0m", "The package react-particles-js has been deprecated and is not supported anymore. Please consider switching to react-tsparticles package.");
|
|
25
|
+
|
|
26
|
+
throw new Error(reactParticlesJsFoundError);
|
|
27
|
+
}
|
|
28
|
+
|
|
22
29
|
if (dependencies["react"] || dependencies["next"]) {
|
|
23
30
|
if (!dependencies["react-tsparticles"]) {
|
|
24
31
|
console.warn("\x1b[43m\x1b[30m%s\x1b[0m", "Found React installed. Please download react-tsparticles to use tsParticles with a component ready to use and easier to configure.");
|
|
@@ -81,5 +88,9 @@ try {
|
|
|
81
88
|
}
|
|
82
89
|
}
|
|
83
90
|
} catch (error) {
|
|
84
|
-
|
|
91
|
+
if (error.message === reactParticlesJsFoundError) {
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
console.log(error);
|
|
85
96
|
}
|
package/tsparticles.js
CHANGED
|
@@ -1222,14 +1222,11 @@
|
|
|
1222
1222
|
};
|
|
1223
1223
|
}
|
|
1224
1224
|
function circleBounce(p1, p2) {
|
|
1225
|
-
const xVelocityDiff = p1.velocity.
|
|
1226
|
-
const
|
|
1227
|
-
const
|
|
1228
|
-
const pos2 = p2.position;
|
|
1229
|
-
const xDist = pos2.x - pos1.x;
|
|
1230
|
-
const yDist = pos2.y - pos1.y;
|
|
1225
|
+
const {x: xVelocityDiff, y: yVelocityDiff} = p1.velocity.sub(p2.velocity);
|
|
1226
|
+
const [pos1, pos2] = [ p1.position, p2.position ];
|
|
1227
|
+
const {dx: xDist, dy: yDist} = getDistances(pos2, pos1);
|
|
1231
1228
|
if (xVelocityDiff * xDist + yVelocityDiff * yDist >= 0) {
|
|
1232
|
-
const angle = -Math.atan2(
|
|
1229
|
+
const angle = -Math.atan2(yDist, xDist);
|
|
1233
1230
|
const m1 = p1.mass;
|
|
1234
1231
|
const m2 = p2.mass;
|
|
1235
1232
|
const u1 = p1.velocity.rotate(angle);
|
|
@@ -2163,6 +2160,7 @@
|
|
|
2163
2160
|
this.mouseDownHandler = () => this.mouseDown();
|
|
2164
2161
|
this.visibilityChangeHandler = () => this.handleVisibilityChange();
|
|
2165
2162
|
this.themeChangeHandler = e => this.handleThemeChange(e);
|
|
2163
|
+
this.oldThemeChangeHandler = e => this.handleThemeChange(e);
|
|
2166
2164
|
this.resizeHandler = () => this.handleWindowResize();
|
|
2167
2165
|
}
|
|
2168
2166
|
addListeners() {
|
|
@@ -2186,9 +2184,17 @@
|
|
|
2186
2184
|
} else {
|
|
2187
2185
|
container.interactivity.element = container.canvas.element;
|
|
2188
2186
|
}
|
|
2189
|
-
const mediaMatch = typeof matchMedia !== "undefined" && matchMedia("(prefers-color-scheme: dark)");
|
|
2187
|
+
const mediaMatch = !isSsr() && typeof matchMedia !== "undefined" && matchMedia("(prefers-color-scheme: dark)");
|
|
2190
2188
|
if (mediaMatch) {
|
|
2191
|
-
|
|
2189
|
+
if (mediaMatch.addEventListener !== undefined) {
|
|
2190
|
+
manageListener(mediaMatch, "change", this.themeChangeHandler, add);
|
|
2191
|
+
} else if (mediaMatch.addListener !== undefined) {
|
|
2192
|
+
if (add) {
|
|
2193
|
+
mediaMatch.addListener(this.oldThemeChangeHandler);
|
|
2194
|
+
} else {
|
|
2195
|
+
mediaMatch.removeListener(this.oldThemeChangeHandler);
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2192
2198
|
}
|
|
2193
2199
|
const interactivityEl = container.interactivity.element;
|
|
2194
2200
|
if (!interactivityEl) {
|
|
@@ -9420,7 +9426,7 @@
|
|
|
9420
9426
|
}
|
|
9421
9427
|
class AbsorberInstance {
|
|
9422
9428
|
constructor(absorbers, container, options, position) {
|
|
9423
|
-
var _a, _b, _c;
|
|
9429
|
+
var _a, _b, _c, _d, _e;
|
|
9424
9430
|
this.absorbers = absorbers;
|
|
9425
9431
|
this.container = container;
|
|
9426
9432
|
this.initialPosition = position ? Vector.create(position.x, position.y) : undefined;
|
|
@@ -9431,16 +9437,22 @@
|
|
|
9431
9437
|
this.size = getRangeValue(options.size.value) * container.retina.pixelRatio;
|
|
9432
9438
|
this.mass = this.size * options.size.density * container.retina.reduceFactor;
|
|
9433
9439
|
const limit = options.size.limit;
|
|
9434
|
-
this.limit = limit
|
|
9440
|
+
this.limit = typeof limit === "number" ? {
|
|
9441
|
+
radius: limit * container.retina.pixelRatio * container.retina.reduceFactor,
|
|
9442
|
+
mass: 0
|
|
9443
|
+
} : {
|
|
9444
|
+
radius: ((_a = limit === null || limit === void 0 ? void 0 : limit.radius) !== null && _a !== void 0 ? _a : 0) * container.retina.pixelRatio * container.retina.reduceFactor,
|
|
9445
|
+
mass: (_b = limit === null || limit === void 0 ? void 0 : limit.mass) !== null && _b !== void 0 ? _b : 0
|
|
9446
|
+
};
|
|
9435
9447
|
const color = typeof options.color === "string" ? {
|
|
9436
9448
|
value: options.color
|
|
9437
9449
|
} : options.color;
|
|
9438
|
-
this.color = (
|
|
9450
|
+
this.color = (_c = colorToRgb(color)) !== null && _c !== void 0 ? _c : {
|
|
9439
9451
|
b: 0,
|
|
9440
9452
|
g: 0,
|
|
9441
9453
|
r: 0
|
|
9442
9454
|
};
|
|
9443
|
-
this.position = (
|
|
9455
|
+
this.position = (_e = (_d = this.initialPosition) === null || _d === void 0 ? void 0 : _d.copy()) !== null && _e !== void 0 ? _e : this.calcPosition();
|
|
9444
9456
|
}
|
|
9445
9457
|
attract(particle) {
|
|
9446
9458
|
const container = this.container;
|
|
@@ -9479,10 +9491,12 @@
|
|
|
9479
9491
|
}
|
|
9480
9492
|
this.updateParticlePosition(particle, v);
|
|
9481
9493
|
}
|
|
9482
|
-
if (this.limit
|
|
9494
|
+
if (this.limit.radius <= 0 || this.size < this.limit.radius) {
|
|
9483
9495
|
this.size += sizeFactor;
|
|
9484
9496
|
}
|
|
9485
|
-
this.mass
|
|
9497
|
+
if (this.limit.mass <= 0 || this.mass < this.limit.mass) {
|
|
9498
|
+
this.mass += sizeFactor * this.options.size.density * container.retina.reduceFactor;
|
|
9499
|
+
}
|
|
9486
9500
|
} else {
|
|
9487
9501
|
this.updateParticlePosition(particle, v);
|
|
9488
9502
|
}
|
|
@@ -9513,9 +9527,10 @@
|
|
|
9513
9527
|
const container = this.container;
|
|
9514
9528
|
const canvasSize = container.canvas.size;
|
|
9515
9529
|
if (particle.needsNewPosition) {
|
|
9516
|
-
|
|
9517
|
-
particle.position.
|
|
9518
|
-
particle.
|
|
9530
|
+
particle.position.x = Math.floor(Math.random() * canvasSize.width);
|
|
9531
|
+
particle.position.y = Math.floor(Math.random() * canvasSize.height);
|
|
9532
|
+
particle.velocity.setTo(particle.initialVelocity);
|
|
9533
|
+
particle.absorberOrbit = undefined;
|
|
9519
9534
|
particle.needsNewPosition = false;
|
|
9520
9535
|
}
|
|
9521
9536
|
if (this.options.orbits) {
|
|
@@ -9552,12 +9567,30 @@
|
|
|
9552
9567
|
}
|
|
9553
9568
|
}
|
|
9554
9569
|
}
|
|
9570
|
+
class AbsorberSizeLimit {
|
|
9571
|
+
constructor() {
|
|
9572
|
+
this.radius = 0;
|
|
9573
|
+
this.mass = 0;
|
|
9574
|
+
}
|
|
9575
|
+
load(data) {
|
|
9576
|
+
if (!data) {
|
|
9577
|
+
return;
|
|
9578
|
+
}
|
|
9579
|
+
if (data.mass !== undefined) {
|
|
9580
|
+
this.mass = data.mass;
|
|
9581
|
+
}
|
|
9582
|
+
if (data.radius !== undefined) {
|
|
9583
|
+
this.radius = data.radius;
|
|
9584
|
+
}
|
|
9585
|
+
}
|
|
9586
|
+
}
|
|
9555
9587
|
class AbsorberSize extends ValueWithRandom {
|
|
9556
9588
|
constructor() {
|
|
9557
9589
|
super();
|
|
9558
9590
|
this.density = 5;
|
|
9559
9591
|
this.random.minimumValue = 1;
|
|
9560
9592
|
this.value = 50;
|
|
9593
|
+
this.limit = new AbsorberSizeLimit;
|
|
9561
9594
|
}
|
|
9562
9595
|
load(data) {
|
|
9563
9596
|
if (!data) {
|
|
@@ -9567,11 +9600,10 @@
|
|
|
9567
9600
|
if (data.density !== undefined) {
|
|
9568
9601
|
this.density = data.density;
|
|
9569
9602
|
}
|
|
9570
|
-
if (data.limit
|
|
9571
|
-
this.limit = data.limit;
|
|
9572
|
-
}
|
|
9573
|
-
|
|
9574
|
-
this.limit = data.limit;
|
|
9603
|
+
if (typeof data.limit === "number") {
|
|
9604
|
+
this.limit.radius = data.limit;
|
|
9605
|
+
} else {
|
|
9606
|
+
this.limit.load(data.limit);
|
|
9575
9607
|
}
|
|
9576
9608
|
}
|
|
9577
9609
|
}
|