@tsparticles/move-base 3.8.0 → 3.9.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/BaseMover.js +3 -3
- package/browser/Utils.js +10 -7
- package/browser/index.js +1 -1
- package/cjs/BaseMover.js +3 -3
- package/cjs/Utils.js +10 -7
- package/cjs/index.js +1 -1
- package/esm/BaseMover.js +3 -3
- package/esm/Utils.js +10 -7
- package/esm/index.js +1 -1
- package/package.json +2 -2
- package/report.html +1 -1
- package/tsparticles.move.base.js +4 -4
- package/tsparticles.move.base.min.js +1 -1
- package/tsparticles.move.base.min.js.LICENSE.txt +1 -1
- package/types/Utils.d.ts +2 -2
- package/umd/BaseMover.js +3 -3
- package/umd/Utils.js +10 -7
- package/umd/index.js +1 -1
package/browser/BaseMover.js
CHANGED
|
@@ -22,12 +22,12 @@ export class BaseMover {
|
|
|
22
22
|
const container = particle.container, pxRatio = container.retina.pixelRatio;
|
|
23
23
|
particle.retina.moveSpeed ??= getRangeValue(moveOptions.speed) * pxRatio;
|
|
24
24
|
particle.retina.moveDrift ??= getRangeValue(particle.options.move.drift) * pxRatio;
|
|
25
|
-
const slowFactor = getProximitySpeedFactor(particle),
|
|
25
|
+
const slowFactor = getProximitySpeedFactor(particle), reduceFactor = container.retina.reduceFactor, baseSpeed = particle.retina.moveSpeed, moveDrift = particle.retina.moveDrift, maxSize = getRangeMax(particleOptions.size.value) * pxRatio, sizeFactor = moveOptions.size ? particle.getRadius() / maxSize : defaultSizeFactor, deltaFactor = delta.factor || defaultDeltaFactor, moveSpeed = (baseSpeed * sizeFactor * slowFactor * deltaFactor) / diffFactor, maxSpeed = particle.retina.maxSpeed ?? container.retina.maxSpeed;
|
|
26
26
|
if (moveOptions.spin.enable) {
|
|
27
|
-
spin(particle, moveSpeed);
|
|
27
|
+
spin(particle, moveSpeed, reduceFactor);
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
|
-
move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, delta);
|
|
30
|
+
move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFactor, delta);
|
|
31
31
|
}
|
|
32
32
|
applyDistance(particle);
|
|
33
33
|
}
|
package/browser/Utils.js
CHANGED
|
@@ -30,7 +30,7 @@ export function applyDistance(particle) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
export function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, delta) {
|
|
33
|
+
export function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFactor, delta) {
|
|
34
34
|
applyPath(particle, delta);
|
|
35
35
|
const gravityOptions = particle.gravity, gravityFactor = gravityOptions?.enable && gravityOptions.inverse ? -identity : identity;
|
|
36
36
|
if (moveDrift && moveSpeed) {
|
|
@@ -54,14 +54,15 @@ export function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, delt
|
|
|
54
54
|
}
|
|
55
55
|
const zIndexOptions = particle.options.zIndex, zVelocityFactor = (identity - particle.zIndexFactor) ** zIndexOptions.velocityRate;
|
|
56
56
|
velocity.multTo(zVelocityFactor);
|
|
57
|
+
velocity.multTo(reduceFactor);
|
|
57
58
|
const { position } = particle;
|
|
58
59
|
position.addTo(velocity);
|
|
59
60
|
if (moveOptions.vibrate) {
|
|
60
|
-
position.x += Math.sin(position.x * Math.cos(position.y));
|
|
61
|
-
position.y += Math.cos(position.y * Math.sin(position.x));
|
|
61
|
+
position.x += Math.sin(position.x * Math.cos(position.y)) * reduceFactor;
|
|
62
|
+
position.y += Math.cos(position.y * Math.sin(position.x)) * reduceFactor;
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
|
-
export function spin(particle, moveSpeed) {
|
|
65
|
+
export function spin(particle, moveSpeed, reduceFactor) {
|
|
65
66
|
const container = particle.container;
|
|
66
67
|
if (!particle.spin) {
|
|
67
68
|
return;
|
|
@@ -70,9 +71,11 @@ export function spin(particle, moveSpeed) {
|
|
|
70
71
|
x: spinClockwise ? Math.cos : Math.sin,
|
|
71
72
|
y: spinClockwise ? Math.sin : Math.cos,
|
|
72
73
|
};
|
|
73
|
-
particle.position.x =
|
|
74
|
-
|
|
75
|
-
particle.
|
|
74
|
+
particle.position.x =
|
|
75
|
+
particle.spin.center.x + particle.spin.radius * updateFunc.x(particle.spin.angle) * reduceFactor;
|
|
76
|
+
particle.position.y =
|
|
77
|
+
particle.spin.center.y + particle.spin.radius * updateFunc.y(particle.spin.angle) * reduceFactor;
|
|
78
|
+
particle.spin.radius += particle.spin.acceleration * reduceFactor;
|
|
76
79
|
const maxCanvasSize = Math.max(container.canvas.size.width, container.canvas.size.height), halfMaxSize = maxCanvasSize * half;
|
|
77
80
|
if (particle.spin.radius > halfMaxSize) {
|
|
78
81
|
particle.spin.radius = halfMaxSize;
|
package/browser/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseMover } from "./BaseMover.js";
|
|
2
2
|
export async function loadBaseMover(engine, refresh = true) {
|
|
3
|
-
engine.checkVersion("3.
|
|
3
|
+
engine.checkVersion("3.9.0");
|
|
4
4
|
await engine.addMover("base", () => {
|
|
5
5
|
return Promise.resolve(new BaseMover());
|
|
6
6
|
}, refresh);
|
package/cjs/BaseMover.js
CHANGED
|
@@ -25,12 +25,12 @@ class BaseMover {
|
|
|
25
25
|
const container = particle.container, pxRatio = container.retina.pixelRatio;
|
|
26
26
|
particle.retina.moveSpeed ??= (0, engine_1.getRangeValue)(moveOptions.speed) * pxRatio;
|
|
27
27
|
particle.retina.moveDrift ??= (0, engine_1.getRangeValue)(particle.options.move.drift) * pxRatio;
|
|
28
|
-
const slowFactor = (0, Utils_js_1.getProximitySpeedFactor)(particle),
|
|
28
|
+
const slowFactor = (0, Utils_js_1.getProximitySpeedFactor)(particle), reduceFactor = container.retina.reduceFactor, baseSpeed = particle.retina.moveSpeed, moveDrift = particle.retina.moveDrift, maxSize = (0, engine_1.getRangeMax)(particleOptions.size.value) * pxRatio, sizeFactor = moveOptions.size ? particle.getRadius() / maxSize : defaultSizeFactor, deltaFactor = delta.factor || defaultDeltaFactor, moveSpeed = (baseSpeed * sizeFactor * slowFactor * deltaFactor) / diffFactor, maxSpeed = particle.retina.maxSpeed ?? container.retina.maxSpeed;
|
|
29
29
|
if (moveOptions.spin.enable) {
|
|
30
|
-
(0, Utils_js_1.spin)(particle, moveSpeed);
|
|
30
|
+
(0, Utils_js_1.spin)(particle, moveSpeed, reduceFactor);
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
|
-
(0, Utils_js_1.move)(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, delta);
|
|
33
|
+
(0, Utils_js_1.move)(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFactor, delta);
|
|
34
34
|
}
|
|
35
35
|
(0, Utils_js_1.applyDistance)(particle);
|
|
36
36
|
}
|
package/cjs/Utils.js
CHANGED
|
@@ -38,7 +38,7 @@ function applyDistance(particle) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, delta) {
|
|
41
|
+
function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFactor, delta) {
|
|
42
42
|
applyPath(particle, delta);
|
|
43
43
|
const gravityOptions = particle.gravity, gravityFactor = gravityOptions?.enable && gravityOptions.inverse ? -identity : identity;
|
|
44
44
|
if (moveDrift && moveSpeed) {
|
|
@@ -62,14 +62,15 @@ function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, delta) {
|
|
|
62
62
|
}
|
|
63
63
|
const zIndexOptions = particle.options.zIndex, zVelocityFactor = (identity - particle.zIndexFactor) ** zIndexOptions.velocityRate;
|
|
64
64
|
velocity.multTo(zVelocityFactor);
|
|
65
|
+
velocity.multTo(reduceFactor);
|
|
65
66
|
const { position } = particle;
|
|
66
67
|
position.addTo(velocity);
|
|
67
68
|
if (moveOptions.vibrate) {
|
|
68
|
-
position.x += Math.sin(position.x * Math.cos(position.y));
|
|
69
|
-
position.y += Math.cos(position.y * Math.sin(position.x));
|
|
69
|
+
position.x += Math.sin(position.x * Math.cos(position.y)) * reduceFactor;
|
|
70
|
+
position.y += Math.cos(position.y * Math.sin(position.x)) * reduceFactor;
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
|
-
function spin(particle, moveSpeed) {
|
|
73
|
+
function spin(particle, moveSpeed, reduceFactor) {
|
|
73
74
|
const container = particle.container;
|
|
74
75
|
if (!particle.spin) {
|
|
75
76
|
return;
|
|
@@ -78,9 +79,11 @@ function spin(particle, moveSpeed) {
|
|
|
78
79
|
x: spinClockwise ? Math.cos : Math.sin,
|
|
79
80
|
y: spinClockwise ? Math.sin : Math.cos,
|
|
80
81
|
};
|
|
81
|
-
particle.position.x =
|
|
82
|
-
|
|
83
|
-
particle.
|
|
82
|
+
particle.position.x =
|
|
83
|
+
particle.spin.center.x + particle.spin.radius * updateFunc.x(particle.spin.angle) * reduceFactor;
|
|
84
|
+
particle.position.y =
|
|
85
|
+
particle.spin.center.y + particle.spin.radius * updateFunc.y(particle.spin.angle) * reduceFactor;
|
|
86
|
+
particle.spin.radius += particle.spin.acceleration * reduceFactor;
|
|
84
87
|
const maxCanvasSize = Math.max(container.canvas.size.width, container.canvas.size.height), halfMaxSize = maxCanvasSize * half;
|
|
85
88
|
if (particle.spin.radius > halfMaxSize) {
|
|
86
89
|
particle.spin.radius = halfMaxSize;
|
package/cjs/index.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.loadBaseMover = loadBaseMover;
|
|
4
4
|
const BaseMover_js_1 = require("./BaseMover.js");
|
|
5
5
|
async function loadBaseMover(engine, refresh = true) {
|
|
6
|
-
engine.checkVersion("3.
|
|
6
|
+
engine.checkVersion("3.9.0");
|
|
7
7
|
await engine.addMover("base", () => {
|
|
8
8
|
return Promise.resolve(new BaseMover_js_1.BaseMover());
|
|
9
9
|
}, refresh);
|
package/esm/BaseMover.js
CHANGED
|
@@ -22,12 +22,12 @@ export class BaseMover {
|
|
|
22
22
|
const container = particle.container, pxRatio = container.retina.pixelRatio;
|
|
23
23
|
particle.retina.moveSpeed ??= getRangeValue(moveOptions.speed) * pxRatio;
|
|
24
24
|
particle.retina.moveDrift ??= getRangeValue(particle.options.move.drift) * pxRatio;
|
|
25
|
-
const slowFactor = getProximitySpeedFactor(particle),
|
|
25
|
+
const slowFactor = getProximitySpeedFactor(particle), reduceFactor = container.retina.reduceFactor, baseSpeed = particle.retina.moveSpeed, moveDrift = particle.retina.moveDrift, maxSize = getRangeMax(particleOptions.size.value) * pxRatio, sizeFactor = moveOptions.size ? particle.getRadius() / maxSize : defaultSizeFactor, deltaFactor = delta.factor || defaultDeltaFactor, moveSpeed = (baseSpeed * sizeFactor * slowFactor * deltaFactor) / diffFactor, maxSpeed = particle.retina.maxSpeed ?? container.retina.maxSpeed;
|
|
26
26
|
if (moveOptions.spin.enable) {
|
|
27
|
-
spin(particle, moveSpeed);
|
|
27
|
+
spin(particle, moveSpeed, reduceFactor);
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
|
-
move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, delta);
|
|
30
|
+
move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFactor, delta);
|
|
31
31
|
}
|
|
32
32
|
applyDistance(particle);
|
|
33
33
|
}
|
package/esm/Utils.js
CHANGED
|
@@ -30,7 +30,7 @@ export function applyDistance(particle) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
export function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, delta) {
|
|
33
|
+
export function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFactor, delta) {
|
|
34
34
|
applyPath(particle, delta);
|
|
35
35
|
const gravityOptions = particle.gravity, gravityFactor = gravityOptions?.enable && gravityOptions.inverse ? -identity : identity;
|
|
36
36
|
if (moveDrift && moveSpeed) {
|
|
@@ -54,14 +54,15 @@ export function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, delt
|
|
|
54
54
|
}
|
|
55
55
|
const zIndexOptions = particle.options.zIndex, zVelocityFactor = (identity - particle.zIndexFactor) ** zIndexOptions.velocityRate;
|
|
56
56
|
velocity.multTo(zVelocityFactor);
|
|
57
|
+
velocity.multTo(reduceFactor);
|
|
57
58
|
const { position } = particle;
|
|
58
59
|
position.addTo(velocity);
|
|
59
60
|
if (moveOptions.vibrate) {
|
|
60
|
-
position.x += Math.sin(position.x * Math.cos(position.y));
|
|
61
|
-
position.y += Math.cos(position.y * Math.sin(position.x));
|
|
61
|
+
position.x += Math.sin(position.x * Math.cos(position.y)) * reduceFactor;
|
|
62
|
+
position.y += Math.cos(position.y * Math.sin(position.x)) * reduceFactor;
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
|
-
export function spin(particle, moveSpeed) {
|
|
65
|
+
export function spin(particle, moveSpeed, reduceFactor) {
|
|
65
66
|
const container = particle.container;
|
|
66
67
|
if (!particle.spin) {
|
|
67
68
|
return;
|
|
@@ -70,9 +71,11 @@ export function spin(particle, moveSpeed) {
|
|
|
70
71
|
x: spinClockwise ? Math.cos : Math.sin,
|
|
71
72
|
y: spinClockwise ? Math.sin : Math.cos,
|
|
72
73
|
};
|
|
73
|
-
particle.position.x =
|
|
74
|
-
|
|
75
|
-
particle.
|
|
74
|
+
particle.position.x =
|
|
75
|
+
particle.spin.center.x + particle.spin.radius * updateFunc.x(particle.spin.angle) * reduceFactor;
|
|
76
|
+
particle.position.y =
|
|
77
|
+
particle.spin.center.y + particle.spin.radius * updateFunc.y(particle.spin.angle) * reduceFactor;
|
|
78
|
+
particle.spin.radius += particle.spin.acceleration * reduceFactor;
|
|
76
79
|
const maxCanvasSize = Math.max(container.canvas.size.width, container.canvas.size.height), halfMaxSize = maxCanvasSize * half;
|
|
77
80
|
if (particle.spin.radius > halfMaxSize) {
|
|
78
81
|
particle.spin.radius = halfMaxSize;
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseMover } from "./BaseMover.js";
|
|
2
2
|
export async function loadBaseMover(engine, refresh = true) {
|
|
3
|
-
engine.checkVersion("3.
|
|
3
|
+
engine.checkVersion("3.9.0");
|
|
4
4
|
await engine.addMover("base", () => {
|
|
5
5
|
return Promise.resolve(new BaseMover());
|
|
6
6
|
}, refresh);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/move-base",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "tsParticles Base movement",
|
|
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.
|
|
90
|
+
"@tsparticles/engine": "3.9.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/move-base [
|
|
6
|
+
<title>@tsparticles/move-base [1 Aug 2025 at 08:43]</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>
|
package/tsparticles.move.base.js
CHANGED
|
@@ -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.
|
|
7
|
+
* v3.9.0
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -34,7 +34,7 @@ return /******/ (() => { // webpackBootstrap
|
|
|
34
34
|
\***********************************/
|
|
35
35
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
36
36
|
|
|
37
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BaseMover: () => (/* binding */ BaseMover)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\nconst diffFactor = 2,\n defaultSizeFactor = 1,\n defaultDeltaFactor = 1;\nclass BaseMover {\n init(particle) {\n const options = particle.options,\n gravityOptions = options.move.gravity;\n particle.gravity = {\n enable: gravityOptions.enable,\n acceleration: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(gravityOptions.acceleration),\n inverse: gravityOptions.inverse\n };\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.initSpin)(particle);\n }\n isEnabled(particle) {\n return !particle.destroyed && particle.options.move.enable;\n }\n move(particle, delta) {\n const particleOptions = particle.options,\n moveOptions = particleOptions.move;\n if (!moveOptions.enable) {\n return;\n }\n const container = particle.container,\n pxRatio = container.retina.pixelRatio;\n particle.retina.moveSpeed ??= (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(moveOptions.speed) * pxRatio;\n particle.retina.moveDrift ??= (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(particle.options.move.drift) * pxRatio;\n const slowFactor = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.getProximitySpeedFactor)(particle),\n
|
|
37
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BaseMover: () => (/* binding */ BaseMover)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\nconst diffFactor = 2,\n defaultSizeFactor = 1,\n defaultDeltaFactor = 1;\nclass BaseMover {\n init(particle) {\n const options = particle.options,\n gravityOptions = options.move.gravity;\n particle.gravity = {\n enable: gravityOptions.enable,\n acceleration: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(gravityOptions.acceleration),\n inverse: gravityOptions.inverse\n };\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.initSpin)(particle);\n }\n isEnabled(particle) {\n return !particle.destroyed && particle.options.move.enable;\n }\n move(particle, delta) {\n const particleOptions = particle.options,\n moveOptions = particleOptions.move;\n if (!moveOptions.enable) {\n return;\n }\n const container = particle.container,\n pxRatio = container.retina.pixelRatio;\n particle.retina.moveSpeed ??= (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(moveOptions.speed) * pxRatio;\n particle.retina.moveDrift ??= (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(particle.options.move.drift) * pxRatio;\n const slowFactor = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.getProximitySpeedFactor)(particle),\n reduceFactor = container.retina.reduceFactor,\n baseSpeed = particle.retina.moveSpeed,\n moveDrift = particle.retina.moveDrift,\n maxSize = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeMax)(particleOptions.size.value) * pxRatio,\n sizeFactor = moveOptions.size ? particle.getRadius() / maxSize : defaultSizeFactor,\n deltaFactor = delta.factor || defaultDeltaFactor,\n moveSpeed = baseSpeed * sizeFactor * slowFactor * deltaFactor / diffFactor,\n maxSpeed = particle.retina.maxSpeed ?? container.retina.maxSpeed;\n if (moveOptions.spin.enable) {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.spin)(particle, moveSpeed, reduceFactor);\n } else {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.move)(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFactor, delta);\n }\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.applyDistance)(particle);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/move-base/./dist/browser/BaseMover.js?\n}");
|
|
38
38
|
|
|
39
39
|
/***/ }),
|
|
40
40
|
|
|
@@ -44,7 +44,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
44
44
|
\*******************************/
|
|
45
45
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
46
46
|
|
|
47
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ applyDistance: () => (/* binding */ applyDistance),\n/* harmony export */ applyPath: () => (/* binding */ applyPath),\n/* harmony export */ getProximitySpeedFactor: () => (/* binding */ getProximitySpeedFactor),\n/* harmony export */ initSpin: () => (/* binding */ initSpin),\n/* harmony export */ move: () => (/* binding */ move),\n/* harmony export */ spin: () => (/* binding */ spin)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst half = 0.5,\n double = 2,\n minVelocity = 0,\n identity = 1,\n moveSpeedFactor = 60,\n minSpinRadius = 0,\n spinFactor = 0.01,\n doublePI = Math.PI * double;\nfunction applyDistance(particle) {\n const initialPosition = particle.initialPosition,\n {\n dx,\n dy\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(initialPosition, particle.position),\n dxFixed = Math.abs(dx),\n dyFixed = Math.abs(dy),\n {\n maxDistance\n } = particle.retina,\n hDistance = maxDistance.horizontal,\n vDistance = maxDistance.vertical;\n if (!hDistance && !vDistance) {\n return;\n }\n const hasHDistance = (hDistance && dxFixed >= hDistance) ?? false,\n hasVDistance = (vDistance && dyFixed >= vDistance) ?? false;\n if ((hasHDistance || hasVDistance) && !particle.misplaced) {\n particle.misplaced = !!hDistance && dxFixed > hDistance || !!vDistance && dyFixed > vDistance;\n if (hDistance) {\n particle.velocity.x = particle.velocity.y * half - particle.velocity.x;\n }\n if (vDistance) {\n particle.velocity.y = particle.velocity.x * half - particle.velocity.y;\n }\n } else if ((!hDistance || dxFixed < hDistance) && (!vDistance || dyFixed < vDistance) && particle.misplaced) {\n particle.misplaced = false;\n } else if (particle.misplaced) {\n const pos = particle.position,\n vel = particle.velocity;\n if (hDistance && (pos.x < initialPosition.x && vel.x < minVelocity || pos.x > initialPosition.x && vel.x > minVelocity)) {\n vel.x *= -(0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)();\n }\n if (vDistance && (pos.y < initialPosition.y && vel.y < minVelocity || pos.y > initialPosition.y && vel.y > minVelocity)) {\n vel.y *= -(0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)();\n }\n }\n}\nfunction move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, delta) {\n applyPath(particle, delta);\n const gravityOptions = particle.gravity,\n gravityFactor = gravityOptions?.enable && gravityOptions.inverse ? -identity : identity;\n if (moveDrift && moveSpeed) {\n particle.velocity.x += moveDrift * delta.factor / (moveSpeedFactor * moveSpeed);\n }\n if (gravityOptions?.enable && moveSpeed) {\n particle.velocity.y += gravityFactor * (gravityOptions.acceleration * delta.factor) / (moveSpeedFactor * moveSpeed);\n }\n const decay = particle.moveDecay;\n particle.velocity.multTo(decay);\n const velocity = particle.velocity.mult(moveSpeed);\n if (gravityOptions?.enable && maxSpeed > minVelocity && (!gravityOptions.inverse && velocity.y >= minVelocity && velocity.y >= maxSpeed || gravityOptions.inverse && velocity.y <= minVelocity && velocity.y <= -maxSpeed)) {\n velocity.y = gravityFactor * maxSpeed;\n if (moveSpeed) {\n particle.velocity.y = velocity.y / moveSpeed;\n }\n }\n const zIndexOptions = particle.options.zIndex,\n zVelocityFactor = (identity - particle.zIndexFactor) ** zIndexOptions.velocityRate;\n velocity.multTo(zVelocityFactor);\n const {\n position\n } = particle;\n position.addTo(velocity);\n if (moveOptions.vibrate) {\n position.x += Math.sin(position.x * Math.cos(position.y));\n position.y += Math.cos(position.y * Math.sin(position.x));\n }\n}\nfunction spin(particle, moveSpeed) {\n const container = particle.container;\n if (!particle.spin) {\n return;\n }\n const spinClockwise = particle.spin.direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.RotateDirection.clockwise,\n updateFunc = {\n x: spinClockwise ? Math.cos : Math.sin,\n y: spinClockwise ? Math.sin : Math.cos\n };\n particle.position.x = particle.spin.center.x + particle.spin.radius * updateFunc.x(particle.spin.angle);\n particle.position.y = particle.spin.center.y + particle.spin.radius * updateFunc.y(particle.spin.angle);\n particle.spin.radius += particle.spin.acceleration;\n const maxCanvasSize = Math.max(container.canvas.size.width, container.canvas.size.height),\n halfMaxSize = maxCanvasSize * half;\n if (particle.spin.radius > halfMaxSize) {\n particle.spin.radius = halfMaxSize;\n particle.spin.acceleration *= -identity;\n } else if (particle.spin.radius < minSpinRadius) {\n particle.spin.radius = minSpinRadius;\n particle.spin.acceleration *= -identity;\n }\n particle.spin.angle += moveSpeed * spinFactor * (identity - particle.spin.radius / maxCanvasSize);\n}\nfunction applyPath(particle, delta) {\n const particlesOptions = particle.options,\n pathOptions = particlesOptions.move.path,\n pathEnabled = pathOptions.enable;\n if (!pathEnabled) {\n return;\n }\n if (particle.lastPathTime <= particle.pathDelay) {\n particle.lastPathTime += delta.value;\n return;\n }\n const path = particle.pathGenerator?.generate(particle, delta);\n if (path) {\n particle.velocity.addTo(path);\n }\n if (pathOptions.clamp) {\n particle.velocity.x = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.clamp)(particle.velocity.x, -identity, identity);\n particle.velocity.y = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.clamp)(particle.velocity.y, -identity, identity);\n }\n particle.lastPathTime -= particle.pathDelay;\n}\nfunction getProximitySpeedFactor(particle) {\n return particle.slow.inRange ? particle.slow.factor : identity;\n}\nfunction initSpin(particle) {\n const container = particle.container,\n options = particle.options,\n spinOptions = options.move.spin;\n if (!spinOptions.enable) {\n return;\n }\n const spinPos = spinOptions.position ?? {\n x: 50,\n y: 50\n },\n spinFactor = 0.01,\n spinCenter = {\n x: spinPos.x * spinFactor * container.canvas.size.width,\n y: spinPos.y * spinFactor * container.canvas.size.height\n },\n pos = particle.getPosition(),\n distance = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistance)(pos, spinCenter),\n spinAcceleration = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(spinOptions.acceleration);\n particle.retina.spinAcceleration = spinAcceleration * container.retina.pixelRatio;\n particle.spin = {\n center: spinCenter,\n direction: particle.velocity.x >= minVelocity ? _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.RotateDirection.clockwise : _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.RotateDirection.counterClockwise,\n angle: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * doublePI,\n radius: distance,\n acceleration: particle.retina.spinAcceleration\n };\n}\n\n//# sourceURL=webpack://@tsparticles/move-base/./dist/browser/Utils.js
|
|
47
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ applyDistance: () => (/* binding */ applyDistance),\n/* harmony export */ applyPath: () => (/* binding */ applyPath),\n/* harmony export */ getProximitySpeedFactor: () => (/* binding */ getProximitySpeedFactor),\n/* harmony export */ initSpin: () => (/* binding */ initSpin),\n/* harmony export */ move: () => (/* binding */ move),\n/* harmony export */ spin: () => (/* binding */ spin)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst half = 0.5,\n double = 2,\n minVelocity = 0,\n identity = 1,\n moveSpeedFactor = 60,\n minSpinRadius = 0,\n spinFactor = 0.01,\n doublePI = Math.PI * double;\nfunction applyDistance(particle) {\n const initialPosition = particle.initialPosition,\n {\n dx,\n dy\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(initialPosition, particle.position),\n dxFixed = Math.abs(dx),\n dyFixed = Math.abs(dy),\n {\n maxDistance\n } = particle.retina,\n hDistance = maxDistance.horizontal,\n vDistance = maxDistance.vertical;\n if (!hDistance && !vDistance) {\n return;\n }\n const hasHDistance = (hDistance && dxFixed >= hDistance) ?? false,\n hasVDistance = (vDistance && dyFixed >= vDistance) ?? false;\n if ((hasHDistance || hasVDistance) && !particle.misplaced) {\n particle.misplaced = !!hDistance && dxFixed > hDistance || !!vDistance && dyFixed > vDistance;\n if (hDistance) {\n particle.velocity.x = particle.velocity.y * half - particle.velocity.x;\n }\n if (vDistance) {\n particle.velocity.y = particle.velocity.x * half - particle.velocity.y;\n }\n } else if ((!hDistance || dxFixed < hDistance) && (!vDistance || dyFixed < vDistance) && particle.misplaced) {\n particle.misplaced = false;\n } else if (particle.misplaced) {\n const pos = particle.position,\n vel = particle.velocity;\n if (hDistance && (pos.x < initialPosition.x && vel.x < minVelocity || pos.x > initialPosition.x && vel.x > minVelocity)) {\n vel.x *= -(0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)();\n }\n if (vDistance && (pos.y < initialPosition.y && vel.y < minVelocity || pos.y > initialPosition.y && vel.y > minVelocity)) {\n vel.y *= -(0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)();\n }\n }\n}\nfunction move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFactor, delta) {\n applyPath(particle, delta);\n const gravityOptions = particle.gravity,\n gravityFactor = gravityOptions?.enable && gravityOptions.inverse ? -identity : identity;\n if (moveDrift && moveSpeed) {\n particle.velocity.x += moveDrift * delta.factor / (moveSpeedFactor * moveSpeed);\n }\n if (gravityOptions?.enable && moveSpeed) {\n particle.velocity.y += gravityFactor * (gravityOptions.acceleration * delta.factor) / (moveSpeedFactor * moveSpeed);\n }\n const decay = particle.moveDecay;\n particle.velocity.multTo(decay);\n const velocity = particle.velocity.mult(moveSpeed);\n if (gravityOptions?.enable && maxSpeed > minVelocity && (!gravityOptions.inverse && velocity.y >= minVelocity && velocity.y >= maxSpeed || gravityOptions.inverse && velocity.y <= minVelocity && velocity.y <= -maxSpeed)) {\n velocity.y = gravityFactor * maxSpeed;\n if (moveSpeed) {\n particle.velocity.y = velocity.y / moveSpeed;\n }\n }\n const zIndexOptions = particle.options.zIndex,\n zVelocityFactor = (identity - particle.zIndexFactor) ** zIndexOptions.velocityRate;\n velocity.multTo(zVelocityFactor);\n velocity.multTo(reduceFactor);\n const {\n position\n } = particle;\n position.addTo(velocity);\n if (moveOptions.vibrate) {\n position.x += Math.sin(position.x * Math.cos(position.y)) * reduceFactor;\n position.y += Math.cos(position.y * Math.sin(position.x)) * reduceFactor;\n }\n}\nfunction spin(particle, moveSpeed, reduceFactor) {\n const container = particle.container;\n if (!particle.spin) {\n return;\n }\n const spinClockwise = particle.spin.direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.RotateDirection.clockwise,\n updateFunc = {\n x: spinClockwise ? Math.cos : Math.sin,\n y: spinClockwise ? Math.sin : Math.cos\n };\n particle.position.x = particle.spin.center.x + particle.spin.radius * updateFunc.x(particle.spin.angle) * reduceFactor;\n particle.position.y = particle.spin.center.y + particle.spin.radius * updateFunc.y(particle.spin.angle) * reduceFactor;\n particle.spin.radius += particle.spin.acceleration * reduceFactor;\n const maxCanvasSize = Math.max(container.canvas.size.width, container.canvas.size.height),\n halfMaxSize = maxCanvasSize * half;\n if (particle.spin.radius > halfMaxSize) {\n particle.spin.radius = halfMaxSize;\n particle.spin.acceleration *= -identity;\n } else if (particle.spin.radius < minSpinRadius) {\n particle.spin.radius = minSpinRadius;\n particle.spin.acceleration *= -identity;\n }\n particle.spin.angle += moveSpeed * spinFactor * (identity - particle.spin.radius / maxCanvasSize);\n}\nfunction applyPath(particle, delta) {\n const particlesOptions = particle.options,\n pathOptions = particlesOptions.move.path,\n pathEnabled = pathOptions.enable;\n if (!pathEnabled) {\n return;\n }\n if (particle.lastPathTime <= particle.pathDelay) {\n particle.lastPathTime += delta.value;\n return;\n }\n const path = particle.pathGenerator?.generate(particle, delta);\n if (path) {\n particle.velocity.addTo(path);\n }\n if (pathOptions.clamp) {\n particle.velocity.x = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.clamp)(particle.velocity.x, -identity, identity);\n particle.velocity.y = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.clamp)(particle.velocity.y, -identity, identity);\n }\n particle.lastPathTime -= particle.pathDelay;\n}\nfunction getProximitySpeedFactor(particle) {\n return particle.slow.inRange ? particle.slow.factor : identity;\n}\nfunction initSpin(particle) {\n const container = particle.container,\n options = particle.options,\n spinOptions = options.move.spin;\n if (!spinOptions.enable) {\n return;\n }\n const spinPos = spinOptions.position ?? {\n x: 50,\n y: 50\n },\n spinFactor = 0.01,\n spinCenter = {\n x: spinPos.x * spinFactor * container.canvas.size.width,\n y: spinPos.y * spinFactor * container.canvas.size.height\n },\n pos = particle.getPosition(),\n distance = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistance)(pos, spinCenter),\n spinAcceleration = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(spinOptions.acceleration);\n particle.retina.spinAcceleration = spinAcceleration * container.retina.pixelRatio;\n particle.spin = {\n center: spinCenter,\n direction: particle.velocity.x >= minVelocity ? _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.RotateDirection.clockwise : _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.RotateDirection.counterClockwise,\n angle: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * doublePI,\n radius: distance,\n acceleration: particle.retina.spinAcceleration\n };\n}\n\n//# sourceURL=webpack://@tsparticles/move-base/./dist/browser/Utils.js?\n}");
|
|
48
48
|
|
|
49
49
|
/***/ }),
|
|
50
50
|
|
|
@@ -54,7 +54,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
54
54
|
\*******************************/
|
|
55
55
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
56
56
|
|
|
57
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadBaseMover: () => (/* binding */ loadBaseMover)\n/* harmony export */ });\n/* harmony import */ var _BaseMover_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BaseMover.js */ \"./dist/browser/BaseMover.js\");\n\nasync function loadBaseMover(engine, refresh = true) {\n engine.checkVersion(\"3.
|
|
57
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadBaseMover: () => (/* binding */ loadBaseMover)\n/* harmony export */ });\n/* harmony import */ var _BaseMover_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BaseMover.js */ \"./dist/browser/BaseMover.js\");\n\nasync function loadBaseMover(engine, refresh = true) {\n engine.checkVersion(\"3.9.0\");\n await engine.addMover(\"base\", () => {\n return Promise.resolve(new _BaseMover_js__WEBPACK_IMPORTED_MODULE_0__.BaseMover());\n }, refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/move-base/./dist/browser/index.js?\n}");
|
|
58
58
|
|
|
59
59
|
/***/ }),
|
|
60
60
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.move.base.min.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var i="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var n in i)("object"==typeof exports?exports:e)[n]=i[n]}}(this,(e=>(()=>{var t={303:t=>{t.exports=e}},i={};function n(e){var o=i[e];if(void 0!==o)return o.exports;var a=i[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};n.r(o),n.d(o,{loadBaseMover:()=>
|
|
2
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var i="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var n in i)("object"==typeof exports?exports:e)[n]=i[n]}}(this,(e=>(()=>{var t={303:t=>{t.exports=e}},i={};function n(e){var o=i[e];if(void 0!==o)return o.exports;var a=i[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};n.r(o),n.d(o,{loadBaseMover:()=>l});var a=n(303);const s=2*Math.PI;function r(e,t,i,n,o,s,r){!function(e,t){const i=e.options,n=i.move.path;if(!n.enable)return;if(e.lastPathTime<=e.pathDelay)return void(e.lastPathTime+=t.value);const o=e.pathGenerator?.generate(e,t);o&&e.velocity.addTo(o);n.clamp&&(e.velocity.x=(0,a.clamp)(e.velocity.x,-1,1),e.velocity.y=(0,a.clamp)(e.velocity.y,-1,1));e.lastPathTime-=e.pathDelay}(e,r);const c=e.gravity,l=c?.enable&&c.inverse?-1:1;o&&i&&(e.velocity.x+=o*r.factor/(60*i)),c?.enable&&i&&(e.velocity.y+=l*(c.acceleration*r.factor)/(60*i));const p=e.moveDecay;e.velocity.multTo(p);const y=e.velocity.mult(i);c?.enable&&n>0&&(!c.inverse&&y.y>=0&&y.y>=n||c.inverse&&y.y<=0&&y.y<=-n)&&(y.y=l*n,i&&(e.velocity.y=y.y/i));const v=e.options.zIndex,d=(1-e.zIndexFactor)**v.velocityRate;y.multTo(d),y.multTo(s);const{position:u}=e;u.addTo(y),t.vibrate&&(u.x+=Math.sin(u.x*Math.cos(u.y))*s,u.y+=Math.cos(u.y*Math.sin(u.x))*s)}class c{init(e){const t=e.options.move.gravity;e.gravity={enable:t.enable,acceleration:(0,a.getRangeValue)(t.acceleration),inverse:t.inverse},function(e){const t=e.container,i=e.options.move.spin;if(!i.enable)return;const n=i.position??{x:50,y:50},o={x:.01*n.x*t.canvas.size.width,y:.01*n.y*t.canvas.size.height},r=e.getPosition(),c=(0,a.getDistance)(r,o),l=(0,a.getRangeValue)(i.acceleration);e.retina.spinAcceleration=l*t.retina.pixelRatio,e.spin={center:o,direction:e.velocity.x>=0?a.RotateDirection.clockwise:a.RotateDirection.counterClockwise,angle:(0,a.getRandom)()*s,radius:c,acceleration:e.retina.spinAcceleration}}(e)}isEnabled(e){return!e.destroyed&&e.options.move.enable}move(e,t){const i=e.options,n=i.move;if(!n.enable)return;const o=e.container,s=o.retina.pixelRatio;e.retina.moveSpeed??=(0,a.getRangeValue)(n.speed)*s,e.retina.moveDrift??=(0,a.getRangeValue)(e.options.move.drift)*s;const c=function(e){return e.slow.inRange?e.slow.factor:1}(e),l=o.retina.reduceFactor,p=e.retina.moveSpeed,y=e.retina.moveDrift,v=(0,a.getRangeMax)(i.size.value)*s,d=p*(n.size?e.getRadius()/v:1)*c*(t.factor||1)/2,u=e.retina.maxSpeed??o.retina.maxSpeed;n.spin.enable?function(e,t,i){const n=e.container;if(!e.spin)return;const o=e.spin.direction===a.RotateDirection.clockwise,s={x:o?Math.cos:Math.sin,y:o?Math.sin:Math.cos};e.position.x=e.spin.center.x+e.spin.radius*s.x(e.spin.angle)*i,e.position.y=e.spin.center.y+e.spin.radius*s.y(e.spin.angle)*i,e.spin.radius+=e.spin.acceleration*i;const r=Math.max(n.canvas.size.width,n.canvas.size.height),c=.5*r;e.spin.radius>c?(e.spin.radius=c,e.spin.acceleration*=-1):e.spin.radius<0&&(e.spin.radius=0,e.spin.acceleration*=-1),e.spin.angle+=.01*t*(1-e.spin.radius/r)}(e,d,l):r(e,n,d,u,y,l,t),function(e){const t=e.initialPosition,{dx:i,dy:n}=(0,a.getDistances)(t,e.position),o=Math.abs(i),s=Math.abs(n),{maxDistance:r}=e.retina,c=r.horizontal,l=r.vertical;if(!c&&!l)return;if((c&&o>=c||l&&s>=l)&&!e.misplaced)e.misplaced=!!c&&o>c||!!l&&s>l,c&&(e.velocity.x=.5*e.velocity.y-e.velocity.x),l&&(e.velocity.y=.5*e.velocity.x-e.velocity.y);else if((!c||o<c)&&(!l||s<l)&&e.misplaced)e.misplaced=!1;else if(e.misplaced){const i=e.position,n=e.velocity;c&&(i.x<t.x&&n.x<0||i.x>t.x&&n.x>0)&&(n.x*=-(0,a.getRandom)()),l&&(i.y<t.y&&n.y<0||i.y>t.y&&n.y>0)&&(n.y*=-(0,a.getRandom)())}}(e)}}async function l(e,t=!0){e.checkVersion("3.9.0"),await e.addMover("base",(()=>Promise.resolve(new c)),t)}return o})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Base Move v3.
|
|
1
|
+
/*! tsParticles Base Move v3.9.0 by Matteo Bruni */
|
package/types/Utils.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type IDelta, type Move, type Particle } from "@tsparticles/engine";
|
|
2
2
|
import type { MoveParticle } from "./Types.js";
|
|
3
3
|
export declare function applyDistance(particle: MoveParticle): void;
|
|
4
|
-
export declare function move(particle: MoveParticle, moveOptions: Move, moveSpeed: number, maxSpeed: number, moveDrift: number, delta: IDelta): void;
|
|
5
|
-
export declare function spin(particle: MoveParticle, moveSpeed: number): void;
|
|
4
|
+
export declare function move(particle: MoveParticle, moveOptions: Move, moveSpeed: number, maxSpeed: number, moveDrift: number, reduceFactor: number, delta: IDelta): void;
|
|
5
|
+
export declare function spin(particle: MoveParticle, moveSpeed: number, reduceFactor: number): void;
|
|
6
6
|
export declare function applyPath(particle: Particle, delta: IDelta): void;
|
|
7
7
|
export declare function getProximitySpeedFactor(particle: Particle): number;
|
|
8
8
|
export declare function initSpin(particle: MoveParticle): void;
|
package/umd/BaseMover.js
CHANGED
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
const container = particle.container, pxRatio = container.retina.pixelRatio;
|
|
35
35
|
particle.retina.moveSpeed ??= (0, engine_1.getRangeValue)(moveOptions.speed) * pxRatio;
|
|
36
36
|
particle.retina.moveDrift ??= (0, engine_1.getRangeValue)(particle.options.move.drift) * pxRatio;
|
|
37
|
-
const slowFactor = (0, Utils_js_1.getProximitySpeedFactor)(particle),
|
|
37
|
+
const slowFactor = (0, Utils_js_1.getProximitySpeedFactor)(particle), reduceFactor = container.retina.reduceFactor, baseSpeed = particle.retina.moveSpeed, moveDrift = particle.retina.moveDrift, maxSize = (0, engine_1.getRangeMax)(particleOptions.size.value) * pxRatio, sizeFactor = moveOptions.size ? particle.getRadius() / maxSize : defaultSizeFactor, deltaFactor = delta.factor || defaultDeltaFactor, moveSpeed = (baseSpeed * sizeFactor * slowFactor * deltaFactor) / diffFactor, maxSpeed = particle.retina.maxSpeed ?? container.retina.maxSpeed;
|
|
38
38
|
if (moveOptions.spin.enable) {
|
|
39
|
-
(0, Utils_js_1.spin)(particle, moveSpeed);
|
|
39
|
+
(0, Utils_js_1.spin)(particle, moveSpeed, reduceFactor);
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
|
-
(0, Utils_js_1.move)(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, delta);
|
|
42
|
+
(0, Utils_js_1.move)(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFactor, delta);
|
|
43
43
|
}
|
|
44
44
|
(0, Utils_js_1.applyDistance)(particle);
|
|
45
45
|
}
|
package/umd/Utils.js
CHANGED
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, delta) {
|
|
50
|
+
function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFactor, delta) {
|
|
51
51
|
applyPath(particle, delta);
|
|
52
52
|
const gravityOptions = particle.gravity, gravityFactor = gravityOptions?.enable && gravityOptions.inverse ? -identity : identity;
|
|
53
53
|
if (moveDrift && moveSpeed) {
|
|
@@ -71,14 +71,15 @@
|
|
|
71
71
|
}
|
|
72
72
|
const zIndexOptions = particle.options.zIndex, zVelocityFactor = (identity - particle.zIndexFactor) ** zIndexOptions.velocityRate;
|
|
73
73
|
velocity.multTo(zVelocityFactor);
|
|
74
|
+
velocity.multTo(reduceFactor);
|
|
74
75
|
const { position } = particle;
|
|
75
76
|
position.addTo(velocity);
|
|
76
77
|
if (moveOptions.vibrate) {
|
|
77
|
-
position.x += Math.sin(position.x * Math.cos(position.y));
|
|
78
|
-
position.y += Math.cos(position.y * Math.sin(position.x));
|
|
78
|
+
position.x += Math.sin(position.x * Math.cos(position.y)) * reduceFactor;
|
|
79
|
+
position.y += Math.cos(position.y * Math.sin(position.x)) * reduceFactor;
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
|
-
function spin(particle, moveSpeed) {
|
|
82
|
+
function spin(particle, moveSpeed, reduceFactor) {
|
|
82
83
|
const container = particle.container;
|
|
83
84
|
if (!particle.spin) {
|
|
84
85
|
return;
|
|
@@ -87,9 +88,11 @@
|
|
|
87
88
|
x: spinClockwise ? Math.cos : Math.sin,
|
|
88
89
|
y: spinClockwise ? Math.sin : Math.cos,
|
|
89
90
|
};
|
|
90
|
-
particle.position.x =
|
|
91
|
-
|
|
92
|
-
particle.
|
|
91
|
+
particle.position.x =
|
|
92
|
+
particle.spin.center.x + particle.spin.radius * updateFunc.x(particle.spin.angle) * reduceFactor;
|
|
93
|
+
particle.position.y =
|
|
94
|
+
particle.spin.center.y + particle.spin.radius * updateFunc.y(particle.spin.angle) * reduceFactor;
|
|
95
|
+
particle.spin.radius += particle.spin.acceleration * reduceFactor;
|
|
93
96
|
const maxCanvasSize = Math.max(container.canvas.size.width, container.canvas.size.height), halfMaxSize = maxCanvasSize * half;
|
|
94
97
|
if (particle.spin.radius > halfMaxSize) {
|
|
95
98
|
particle.spin.radius = halfMaxSize;
|
package/umd/index.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
exports.loadBaseMover = loadBaseMover;
|
|
13
13
|
const BaseMover_js_1 = require("./BaseMover.js");
|
|
14
14
|
async function loadBaseMover(engine, refresh = true) {
|
|
15
|
-
engine.checkVersion("3.
|
|
15
|
+
engine.checkVersion("3.9.0");
|
|
16
16
|
await engine.addMover("base", () => {
|
|
17
17
|
return Promise.resolve(new BaseMover_js_1.BaseMover());
|
|
18
18
|
}, refresh);
|