@tsparticles/move-base 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/103.min.js +2 -0
- package/103.min.js.LICENSE.txt +1 -0
- package/460.min.js +2 -0
- package/460.min.js.LICENSE.txt +1 -0
- package/browser/BaseMover.js +11 -28
- package/browser/Utils.js +24 -5
- package/browser/index.js +4 -2
- package/cjs/BaseMover.js +35 -29
- package/cjs/Utils.js +25 -5
- package/cjs/index.js +27 -2
- package/dist_browser_BaseMover_js.js +30 -0
- package/dist_browser_Utils_js.js +30 -0
- package/esm/BaseMover.js +11 -28
- package/esm/Utils.js +24 -5
- package/esm/index.js +4 -2
- package/package.json +2 -2
- package/report.html +3 -3
- package/tsparticles.move.base.js +241 -226
- package/tsparticles.move.base.min.js +1 -1
- package/tsparticles.move.base.min.js.LICENSE.txt +1 -1
- package/types/BaseMover.d.ts +2 -3
- package/types/Utils.d.ts +3 -2
- package/umd/BaseMover.js +37 -30
- package/umd/Utils.js +25 -5
- package/umd/index.js +29 -3
package/umd/BaseMover.js
CHANGED
|
@@ -1,53 +1,57 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
+
}) : function(o, v) {
|
|
15
|
+
o["default"] = v;
|
|
16
|
+
});
|
|
17
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
|
+
if (mod && mod.__esModule) return mod;
|
|
19
|
+
var result = {};
|
|
20
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
__setModuleDefault(result, mod);
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
1
24
|
(function (factory) {
|
|
2
25
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
26
|
var v = factory(require, exports);
|
|
4
27
|
if (v !== undefined) module.exports = v;
|
|
5
28
|
}
|
|
6
29
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "@tsparticles/engine"
|
|
30
|
+
define(["require", "exports", "@tsparticles/engine"], factory);
|
|
8
31
|
}
|
|
9
32
|
})(function (require, exports) {
|
|
10
33
|
"use strict";
|
|
34
|
+
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
11
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
36
|
exports.BaseMover = void 0;
|
|
13
37
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
-
const Utils_js_1 = require("./Utils.js");
|
|
15
38
|
const diffFactor = 2, defaultSizeFactor = 1, defaultDeltaFactor = 1;
|
|
16
39
|
class BaseMover {
|
|
17
|
-
|
|
18
|
-
this._initSpin = (particle) => {
|
|
19
|
-
const container = particle.container, options = particle.options, spinOptions = options.move.spin;
|
|
20
|
-
if (!spinOptions.enable) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const spinPos = spinOptions.position ?? { x: 50, y: 50 }, spinFactor = 0.01, spinCenter = {
|
|
24
|
-
x: spinPos.x * spinFactor * container.canvas.size.width,
|
|
25
|
-
y: spinPos.y * spinFactor * container.canvas.size.height,
|
|
26
|
-
}, pos = particle.getPosition(), distance = (0, engine_1.getDistance)(pos, spinCenter), spinAcceleration = (0, engine_1.getRangeValue)(spinOptions.acceleration);
|
|
27
|
-
particle.retina.spinAcceleration = spinAcceleration * container.retina.pixelRatio;
|
|
28
|
-
const minVelocity = 0;
|
|
29
|
-
particle.spin = {
|
|
30
|
-
center: spinCenter,
|
|
31
|
-
direction: particle.velocity.x >= minVelocity ? "clockwise" : "counter-clockwise",
|
|
32
|
-
angle: particle.velocity.angle,
|
|
33
|
-
radius: distance,
|
|
34
|
-
acceleration: particle.retina.spinAcceleration,
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
init(particle) {
|
|
40
|
+
async init(particle) {
|
|
39
41
|
const options = particle.options, gravityOptions = options.move.gravity;
|
|
40
42
|
particle.gravity = {
|
|
41
43
|
enable: gravityOptions.enable,
|
|
42
44
|
acceleration: (0, engine_1.getRangeValue)(gravityOptions.acceleration),
|
|
43
45
|
inverse: gravityOptions.inverse,
|
|
44
46
|
};
|
|
45
|
-
|
|
47
|
+
const { initSpin } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Utils.js"))) : new Promise((resolve_1, reject_1) => { require(["./Utils.js"], resolve_1, reject_1); }).then(__importStar));
|
|
48
|
+
initSpin(particle);
|
|
49
|
+
await Promise.resolve();
|
|
46
50
|
}
|
|
47
51
|
isEnabled(particle) {
|
|
48
52
|
return !particle.destroyed && particle.options.move.enable;
|
|
49
53
|
}
|
|
50
|
-
move(particle, delta) {
|
|
54
|
+
async move(particle, delta) {
|
|
51
55
|
const particleOptions = particle.options, moveOptions = particleOptions.move;
|
|
52
56
|
if (!moveOptions.enable) {
|
|
53
57
|
return;
|
|
@@ -55,14 +59,17 @@
|
|
|
55
59
|
const container = particle.container, pxRatio = container.retina.pixelRatio;
|
|
56
60
|
particle.retina.moveSpeed ??= (0, engine_1.getRangeValue)(moveOptions.speed) * pxRatio;
|
|
57
61
|
particle.retina.moveDrift ??= (0, engine_1.getRangeValue)(particle.options.move.drift) * pxRatio;
|
|
58
|
-
const
|
|
62
|
+
const { getProximitySpeedFactor } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Utils.js"))) : new Promise((resolve_2, reject_2) => { require(["./Utils.js"], resolve_2, reject_2); }).then(__importStar)), slowFactor = getProximitySpeedFactor(particle), baseSpeed = particle.retina.moveSpeed * container.retina.reduceFactor, 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;
|
|
59
63
|
if (moveOptions.spin.enable) {
|
|
60
|
-
(
|
|
64
|
+
const { spin } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Utils.js"))) : new Promise((resolve_3, reject_3) => { require(["./Utils.js"], resolve_3, reject_3); }).then(__importStar));
|
|
65
|
+
spin(particle, moveSpeed);
|
|
61
66
|
}
|
|
62
67
|
else {
|
|
63
|
-
(
|
|
68
|
+
const { move } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Utils.js"))) : new Promise((resolve_4, reject_4) => { require(["./Utils.js"], resolve_4, reject_4); }).then(__importStar));
|
|
69
|
+
await move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, delta);
|
|
64
70
|
}
|
|
65
|
-
(
|
|
71
|
+
const { applyDistance } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Utils.js"))) : new Promise((resolve_5, reject_5) => { require(["./Utils.js"], resolve_5, reject_5); }).then(__importStar));
|
|
72
|
+
applyDistance(particle);
|
|
66
73
|
}
|
|
67
74
|
}
|
|
68
75
|
exports.BaseMover = BaseMover;
|
package/umd/Utils.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getProximitySpeedFactor = exports.applyPath = exports.spin = exports.move = exports.applyDistance = void 0;
|
|
12
|
+
exports.initSpin = exports.getProximitySpeedFactor = exports.applyPath = exports.spin = exports.move = exports.applyDistance = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
const half = 0.5, minVelocity = 0, identity = 1, moveSpeedFactor = 60, minSpinRadius = 0, spinFactor = 0.01;
|
|
15
15
|
function applyDistance(particle) {
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
exports.applyDistance = applyDistance;
|
|
46
|
-
function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, delta) {
|
|
47
|
-
applyPath(particle, delta);
|
|
46
|
+
async function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, delta) {
|
|
47
|
+
await applyPath(particle, delta);
|
|
48
48
|
const gravityOptions = particle.gravity, gravityFactor = gravityOptions?.enable && gravityOptions.inverse ? -identity : identity;
|
|
49
49
|
if (moveDrift && moveSpeed) {
|
|
50
50
|
particle.velocity.x += (moveDrift * delta.factor) / (moveSpeedFactor * moveSpeed);
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
particle.spin.angle += moveSpeed * spinFactor * (identity - particle.spin.radius / maxCanvasSize);
|
|
100
100
|
}
|
|
101
101
|
exports.spin = spin;
|
|
102
|
-
function applyPath(particle, delta) {
|
|
102
|
+
async function applyPath(particle, delta) {
|
|
103
103
|
const particlesOptions = particle.options, pathOptions = particlesOptions.move.path, pathEnabled = pathOptions.enable;
|
|
104
104
|
if (!pathEnabled) {
|
|
105
105
|
return;
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
particle.lastPathTime += delta.value;
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
|
-
const path = particle.pathGenerator?.generate(particle, delta);
|
|
111
|
+
const path = await particle.pathGenerator?.generate(particle, delta);
|
|
112
112
|
if (path) {
|
|
113
113
|
particle.velocity.addTo(path);
|
|
114
114
|
}
|
|
@@ -123,4 +123,24 @@
|
|
|
123
123
|
return particle.slow.inRange ? particle.slow.factor : identity;
|
|
124
124
|
}
|
|
125
125
|
exports.getProximitySpeedFactor = getProximitySpeedFactor;
|
|
126
|
+
function initSpin(particle) {
|
|
127
|
+
const container = particle.container, options = particle.options, spinOptions = options.move.spin;
|
|
128
|
+
if (!spinOptions.enable) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const spinPos = spinOptions.position ?? { x: 50, y: 50 }, spinFactor = 0.01, spinCenter = {
|
|
132
|
+
x: spinPos.x * spinFactor * container.canvas.size.width,
|
|
133
|
+
y: spinPos.y * spinFactor * container.canvas.size.height,
|
|
134
|
+
}, pos = particle.getPosition(), distance = (0, engine_1.getDistance)(pos, spinCenter), spinAcceleration = (0, engine_1.getRangeValue)(spinOptions.acceleration);
|
|
135
|
+
particle.retina.spinAcceleration = spinAcceleration * container.retina.pixelRatio;
|
|
136
|
+
const minVelocity = 0;
|
|
137
|
+
particle.spin = {
|
|
138
|
+
center: spinCenter,
|
|
139
|
+
direction: particle.velocity.x >= minVelocity ? "clockwise" : "counter-clockwise",
|
|
140
|
+
angle: particle.velocity.angle,
|
|
141
|
+
radius: distance,
|
|
142
|
+
acceleration: particle.retina.spinAcceleration,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
exports.initSpin = initSpin;
|
|
126
146
|
});
|
package/umd/index.js
CHANGED
|
@@ -1,18 +1,44 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
+
}) : function(o, v) {
|
|
15
|
+
o["default"] = v;
|
|
16
|
+
});
|
|
17
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
18
|
+
if (mod && mod.__esModule) return mod;
|
|
19
|
+
var result = {};
|
|
20
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
21
|
+
__setModuleDefault(result, mod);
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
1
24
|
(function (factory) {
|
|
2
25
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
26
|
var v = factory(require, exports);
|
|
4
27
|
if (v !== undefined) module.exports = v;
|
|
5
28
|
}
|
|
6
29
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports"
|
|
30
|
+
define(["require", "exports"], factory);
|
|
8
31
|
}
|
|
9
32
|
})(function (require, exports) {
|
|
10
33
|
"use strict";
|
|
34
|
+
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
11
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
36
|
exports.loadBaseMover = void 0;
|
|
13
|
-
const BaseMover_js_1 = require("./BaseMover.js");
|
|
14
37
|
async function loadBaseMover(engine, refresh = true) {
|
|
15
|
-
await engine.addMover("base", () =>
|
|
38
|
+
await engine.addMover("base", async () => {
|
|
39
|
+
const { BaseMover } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./BaseMover.js"))) : new Promise((resolve_1, reject_1) => { require(["./BaseMover.js"], resolve_1, reject_1); }).then(__importStar));
|
|
40
|
+
return new BaseMover();
|
|
41
|
+
}, refresh);
|
|
16
42
|
}
|
|
17
43
|
exports.loadBaseMover = loadBaseMover;
|
|
18
44
|
});
|