@tsparticles/interaction-external-slow 4.2.1 → 4.3.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/SlowModifier.js +6 -0
- package/browser/Slower.js +23 -6
- package/browser/index.js +2 -1
- package/browser/index.lazy.js +1 -1
- package/cjs/SlowModifier.js +6 -0
- package/cjs/Slower.js +23 -6
- package/cjs/index.js +2 -1
- package/cjs/index.lazy.js +1 -1
- package/esm/SlowModifier.js +6 -0
- package/esm/Slower.js +23 -6
- package/esm/index.js +2 -1
- package/esm/index.lazy.js +1 -1
- package/package.json +3 -3
- package/report.html +1 -1
- package/tsparticles.interaction.external.slow.js +32 -8
- package/tsparticles.interaction.external.slow.min.js +1 -1
- package/types/SlowModifier.d.ts +7 -0
- package/types/Slower.d.ts +2 -0
- package/types/index.d.ts +1 -0
package/browser/Slower.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ExternalInteractorBase, } from "@tsparticles/plugin-interactivity";
|
|
2
2
|
import { getDistance, isInArray, loadOptionProperty, } from "@tsparticles/engine";
|
|
3
3
|
import { Slow } from "./Options/Classes/Slow.js";
|
|
4
|
+
import { SlowModifier } from "./SlowModifier.js";
|
|
4
5
|
const slowMode = "slow", minRadius = 0;
|
|
5
6
|
export class Slower extends ExternalInteractorBase {
|
|
6
7
|
#maxDistance;
|
|
8
|
+
#modifiers = new WeakMap();
|
|
7
9
|
constructor(container) {
|
|
8
10
|
super(container);
|
|
9
11
|
this.#maxDistance = 0;
|
|
@@ -12,10 +14,21 @@ export class Slower extends ExternalInteractorBase {
|
|
|
12
14
|
return this.#maxDistance;
|
|
13
15
|
}
|
|
14
16
|
clear(particle, _delta, force) {
|
|
15
|
-
|
|
17
|
+
const mod = this.#modifiers.get(particle);
|
|
18
|
+
if (mod?.enabled && !force) {
|
|
16
19
|
return;
|
|
17
20
|
}
|
|
18
|
-
particle.
|
|
21
|
+
particle.removeModifier(slowMode);
|
|
22
|
+
this.#modifiers.delete(particle);
|
|
23
|
+
}
|
|
24
|
+
getOrCreateModifier(particle) {
|
|
25
|
+
let mod = this.#modifiers.get(particle);
|
|
26
|
+
if (!mod) {
|
|
27
|
+
mod = new SlowModifier();
|
|
28
|
+
this.#modifiers.set(particle, mod);
|
|
29
|
+
particle.addModifier(mod);
|
|
30
|
+
}
|
|
31
|
+
return mod;
|
|
19
32
|
}
|
|
20
33
|
init() {
|
|
21
34
|
const container = this.container, slow = container.actualOptions.interactivity?.modes.slow;
|
|
@@ -35,16 +48,20 @@ export class Slower extends ExternalInteractorBase {
|
|
|
35
48
|
loadOptionProperty(options, "slow", Slow, ...sources);
|
|
36
49
|
}
|
|
37
50
|
reset(interactivityData, particle) {
|
|
38
|
-
|
|
51
|
+
const mod = this.#modifiers.get(particle);
|
|
52
|
+
if (mod) {
|
|
53
|
+
mod.enabled = false;
|
|
54
|
+
}
|
|
39
55
|
const container = this.container, options = container.actualOptions, mousePos = interactivityData.mouse.position, radius = container.retina.slowModeRadius, slowOptions = options.interactivity?.modes.slow;
|
|
40
56
|
if (!slowOptions || !radius || radius < minRadius || !mousePos) {
|
|
41
57
|
return;
|
|
42
58
|
}
|
|
43
|
-
const particlePos = particle.getPosition(), dist = getDistance(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slowOptions.factor
|
|
59
|
+
const particlePos = particle.getPosition(), dist = getDistance(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slowOptions.factor;
|
|
44
60
|
if (dist > radius) {
|
|
45
61
|
return;
|
|
46
62
|
}
|
|
47
|
-
|
|
48
|
-
|
|
63
|
+
const activeMod = this.getOrCreateModifier(particle);
|
|
64
|
+
activeMod.enabled = true;
|
|
65
|
+
activeMod.speedFactor = proximityFactor / slowFactor;
|
|
49
66
|
}
|
|
50
67
|
}
|
package/browser/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ensureInteractivityPluginLoaded } from "@tsparticles/plugin-interactivity";
|
|
2
2
|
import { Slower } from "./Slower.js";
|
|
3
3
|
export async function loadExternalSlowInteraction(engine) {
|
|
4
|
-
engine.checkVersion("4.
|
|
4
|
+
engine.checkVersion("4.3.0");
|
|
5
5
|
await engine.pluginManager.register((e) => {
|
|
6
6
|
ensureInteractivityPluginLoaded(e);
|
|
7
7
|
e.pluginManager.addInteractor?.("externalSlow", container => {
|
|
@@ -9,4 +9,5 @@ export async function loadExternalSlowInteraction(engine) {
|
|
|
9
9
|
});
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
+
export * from "./SlowModifier.js";
|
|
12
13
|
export * from "./Options/Classes/Slow.js";
|
package/browser/index.lazy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadExternalSlowInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.
|
|
2
|
+
engine.checkVersion("4.3.0");
|
|
3
3
|
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity/lazy");
|
|
5
5
|
ensureInteractivityPluginLoaded(e);
|
package/cjs/Slower.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ExternalInteractorBase, } from "@tsparticles/plugin-interactivity";
|
|
2
2
|
import { getDistance, isInArray, loadOptionProperty, } from "@tsparticles/engine";
|
|
3
3
|
import { Slow } from "./Options/Classes/Slow.js";
|
|
4
|
+
import { SlowModifier } from "./SlowModifier.js";
|
|
4
5
|
const slowMode = "slow", minRadius = 0;
|
|
5
6
|
export class Slower extends ExternalInteractorBase {
|
|
6
7
|
#maxDistance;
|
|
8
|
+
#modifiers = new WeakMap();
|
|
7
9
|
constructor(container) {
|
|
8
10
|
super(container);
|
|
9
11
|
this.#maxDistance = 0;
|
|
@@ -12,10 +14,21 @@ export class Slower extends ExternalInteractorBase {
|
|
|
12
14
|
return this.#maxDistance;
|
|
13
15
|
}
|
|
14
16
|
clear(particle, _delta, force) {
|
|
15
|
-
|
|
17
|
+
const mod = this.#modifiers.get(particle);
|
|
18
|
+
if (mod?.enabled && !force) {
|
|
16
19
|
return;
|
|
17
20
|
}
|
|
18
|
-
particle.
|
|
21
|
+
particle.removeModifier(slowMode);
|
|
22
|
+
this.#modifiers.delete(particle);
|
|
23
|
+
}
|
|
24
|
+
getOrCreateModifier(particle) {
|
|
25
|
+
let mod = this.#modifiers.get(particle);
|
|
26
|
+
if (!mod) {
|
|
27
|
+
mod = new SlowModifier();
|
|
28
|
+
this.#modifiers.set(particle, mod);
|
|
29
|
+
particle.addModifier(mod);
|
|
30
|
+
}
|
|
31
|
+
return mod;
|
|
19
32
|
}
|
|
20
33
|
init() {
|
|
21
34
|
const container = this.container, slow = container.actualOptions.interactivity?.modes.slow;
|
|
@@ -35,16 +48,20 @@ export class Slower extends ExternalInteractorBase {
|
|
|
35
48
|
loadOptionProperty(options, "slow", Slow, ...sources);
|
|
36
49
|
}
|
|
37
50
|
reset(interactivityData, particle) {
|
|
38
|
-
|
|
51
|
+
const mod = this.#modifiers.get(particle);
|
|
52
|
+
if (mod) {
|
|
53
|
+
mod.enabled = false;
|
|
54
|
+
}
|
|
39
55
|
const container = this.container, options = container.actualOptions, mousePos = interactivityData.mouse.position, radius = container.retina.slowModeRadius, slowOptions = options.interactivity?.modes.slow;
|
|
40
56
|
if (!slowOptions || !radius || radius < minRadius || !mousePos) {
|
|
41
57
|
return;
|
|
42
58
|
}
|
|
43
|
-
const particlePos = particle.getPosition(), dist = getDistance(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slowOptions.factor
|
|
59
|
+
const particlePos = particle.getPosition(), dist = getDistance(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slowOptions.factor;
|
|
44
60
|
if (dist > radius) {
|
|
45
61
|
return;
|
|
46
62
|
}
|
|
47
|
-
|
|
48
|
-
|
|
63
|
+
const activeMod = this.getOrCreateModifier(particle);
|
|
64
|
+
activeMod.enabled = true;
|
|
65
|
+
activeMod.speedFactor = proximityFactor / slowFactor;
|
|
49
66
|
}
|
|
50
67
|
}
|
package/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ensureInteractivityPluginLoaded } from "@tsparticles/plugin-interactivity";
|
|
2
2
|
import { Slower } from "./Slower.js";
|
|
3
3
|
export async function loadExternalSlowInteraction(engine) {
|
|
4
|
-
engine.checkVersion("4.
|
|
4
|
+
engine.checkVersion("4.3.0");
|
|
5
5
|
await engine.pluginManager.register((e) => {
|
|
6
6
|
ensureInteractivityPluginLoaded(e);
|
|
7
7
|
e.pluginManager.addInteractor?.("externalSlow", container => {
|
|
@@ -9,4 +9,5 @@ export async function loadExternalSlowInteraction(engine) {
|
|
|
9
9
|
});
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
+
export * from "./SlowModifier.js";
|
|
12
13
|
export * from "./Options/Classes/Slow.js";
|
package/cjs/index.lazy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadExternalSlowInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.
|
|
2
|
+
engine.checkVersion("4.3.0");
|
|
3
3
|
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity/lazy");
|
|
5
5
|
ensureInteractivityPluginLoaded(e);
|
package/esm/Slower.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ExternalInteractorBase, } from "@tsparticles/plugin-interactivity";
|
|
2
2
|
import { getDistance, isInArray, loadOptionProperty, } from "@tsparticles/engine";
|
|
3
3
|
import { Slow } from "./Options/Classes/Slow.js";
|
|
4
|
+
import { SlowModifier } from "./SlowModifier.js";
|
|
4
5
|
const slowMode = "slow", minRadius = 0;
|
|
5
6
|
export class Slower extends ExternalInteractorBase {
|
|
6
7
|
#maxDistance;
|
|
8
|
+
#modifiers = new WeakMap();
|
|
7
9
|
constructor(container) {
|
|
8
10
|
super(container);
|
|
9
11
|
this.#maxDistance = 0;
|
|
@@ -12,10 +14,21 @@ export class Slower extends ExternalInteractorBase {
|
|
|
12
14
|
return this.#maxDistance;
|
|
13
15
|
}
|
|
14
16
|
clear(particle, _delta, force) {
|
|
15
|
-
|
|
17
|
+
const mod = this.#modifiers.get(particle);
|
|
18
|
+
if (mod?.enabled && !force) {
|
|
16
19
|
return;
|
|
17
20
|
}
|
|
18
|
-
particle.
|
|
21
|
+
particle.removeModifier(slowMode);
|
|
22
|
+
this.#modifiers.delete(particle);
|
|
23
|
+
}
|
|
24
|
+
getOrCreateModifier(particle) {
|
|
25
|
+
let mod = this.#modifiers.get(particle);
|
|
26
|
+
if (!mod) {
|
|
27
|
+
mod = new SlowModifier();
|
|
28
|
+
this.#modifiers.set(particle, mod);
|
|
29
|
+
particle.addModifier(mod);
|
|
30
|
+
}
|
|
31
|
+
return mod;
|
|
19
32
|
}
|
|
20
33
|
init() {
|
|
21
34
|
const container = this.container, slow = container.actualOptions.interactivity?.modes.slow;
|
|
@@ -35,16 +48,20 @@ export class Slower extends ExternalInteractorBase {
|
|
|
35
48
|
loadOptionProperty(options, "slow", Slow, ...sources);
|
|
36
49
|
}
|
|
37
50
|
reset(interactivityData, particle) {
|
|
38
|
-
|
|
51
|
+
const mod = this.#modifiers.get(particle);
|
|
52
|
+
if (mod) {
|
|
53
|
+
mod.enabled = false;
|
|
54
|
+
}
|
|
39
55
|
const container = this.container, options = container.actualOptions, mousePos = interactivityData.mouse.position, radius = container.retina.slowModeRadius, slowOptions = options.interactivity?.modes.slow;
|
|
40
56
|
if (!slowOptions || !radius || radius < minRadius || !mousePos) {
|
|
41
57
|
return;
|
|
42
58
|
}
|
|
43
|
-
const particlePos = particle.getPosition(), dist = getDistance(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slowOptions.factor
|
|
59
|
+
const particlePos = particle.getPosition(), dist = getDistance(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slowOptions.factor;
|
|
44
60
|
if (dist > radius) {
|
|
45
61
|
return;
|
|
46
62
|
}
|
|
47
|
-
|
|
48
|
-
|
|
63
|
+
const activeMod = this.getOrCreateModifier(particle);
|
|
64
|
+
activeMod.enabled = true;
|
|
65
|
+
activeMod.speedFactor = proximityFactor / slowFactor;
|
|
49
66
|
}
|
|
50
67
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ensureInteractivityPluginLoaded } from "@tsparticles/plugin-interactivity";
|
|
2
2
|
import { Slower } from "./Slower.js";
|
|
3
3
|
export async function loadExternalSlowInteraction(engine) {
|
|
4
|
-
engine.checkVersion("4.
|
|
4
|
+
engine.checkVersion("4.3.0");
|
|
5
5
|
await engine.pluginManager.register((e) => {
|
|
6
6
|
ensureInteractivityPluginLoaded(e);
|
|
7
7
|
e.pluginManager.addInteractor?.("externalSlow", container => {
|
|
@@ -9,4 +9,5 @@ export async function loadExternalSlowInteraction(engine) {
|
|
|
9
9
|
});
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
+
export * from "./SlowModifier.js";
|
|
12
13
|
export * from "./Options/Classes/Slow.js";
|
package/esm/index.lazy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadExternalSlowInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.
|
|
2
|
+
engine.checkVersion("4.3.0");
|
|
3
3
|
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity/lazy");
|
|
5
5
|
ensureInteractivityPluginLoaded(e);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-external-slow",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "tsParticles slow external interaction",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
},
|
|
98
98
|
"type": "module",
|
|
99
99
|
"peerDependencies": {
|
|
100
|
-
"@tsparticles/engine": "4.
|
|
101
|
-
"@tsparticles/plugin-interactivity": "4.
|
|
100
|
+
"@tsparticles/engine": "4.3.0",
|
|
101
|
+
"@tsparticles/plugin-interactivity": "4.3.0"
|
|
102
102
|
}
|
|
103
103
|
}
|
package/report.html
CHANGED
|
@@ -4930,7 +4930,7 @@ var drawChart = (function (exports) {
|
|
|
4930
4930
|
</script>
|
|
4931
4931
|
<script>
|
|
4932
4932
|
/*<!--*/
|
|
4933
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"tsparticles.interaction.external.slow.js","children":[{"name":"dist/browser","children":[{"name":"Options/Classes/Slow.js","uid":"
|
|
4933
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"tsparticles.interaction.external.slow.js","children":[{"name":"dist/browser","children":[{"name":"Options/Classes/Slow.js","uid":"3c44cba8-1"},{"uid":"3c44cba8-3","name":"SlowModifier.js"},{"uid":"3c44cba8-5","name":"Slower.js"},{"uid":"3c44cba8-7","name":"index.js"},{"uid":"3c44cba8-9","name":"browser.js"}]}]}],"isRoot":true},"nodeParts":{"3c44cba8-1":{"renderedLength":296,"gzipLength":0,"brotliLength":0,"metaUid":"3c44cba8-0"},"3c44cba8-3":{"renderedLength":125,"gzipLength":0,"brotliLength":0,"metaUid":"3c44cba8-2"},"3c44cba8-5":{"renderedLength":2701,"gzipLength":0,"brotliLength":0,"metaUid":"3c44cba8-4"},"3c44cba8-7":{"renderedLength":387,"gzipLength":0,"brotliLength":0,"metaUid":"3c44cba8-6"},"3c44cba8-9":{"renderedLength":197,"gzipLength":0,"brotliLength":0,"metaUid":"3c44cba8-8"}},"nodeMetas":{"3c44cba8-0":{"id":"/dist/browser/Options/Classes/Slow.js","moduleParts":{"tsparticles.interaction.external.slow.js":"3c44cba8-1"},"imported":[{"uid":"3c44cba8-11"}],"importedBy":[{"uid":"3c44cba8-6"},{"uid":"3c44cba8-4"}]},"3c44cba8-2":{"id":"/dist/browser/SlowModifier.js","moduleParts":{"tsparticles.interaction.external.slow.js":"3c44cba8-3"},"imported":[],"importedBy":[{"uid":"3c44cba8-6"},{"uid":"3c44cba8-4"}]},"3c44cba8-4":{"id":"/dist/browser/Slower.js","moduleParts":{"tsparticles.interaction.external.slow.js":"3c44cba8-5"},"imported":[{"uid":"3c44cba8-10"},{"uid":"3c44cba8-11"},{"uid":"3c44cba8-0"},{"uid":"3c44cba8-2"}],"importedBy":[{"uid":"3c44cba8-6"}]},"3c44cba8-6":{"id":"/dist/browser/index.js","moduleParts":{"tsparticles.interaction.external.slow.js":"3c44cba8-7"},"imported":[{"uid":"3c44cba8-10"},{"uid":"3c44cba8-4"},{"uid":"3c44cba8-2"},{"uid":"3c44cba8-0"}],"importedBy":[{"uid":"3c44cba8-8"}]},"3c44cba8-8":{"id":"/dist/browser/browser.js","moduleParts":{"tsparticles.interaction.external.slow.js":"3c44cba8-9"},"imported":[{"uid":"3c44cba8-6"}],"importedBy":[],"isEntry":true},"3c44cba8-10":{"id":"@tsparticles/plugin-interactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"3c44cba8-6"},{"uid":"3c44cba8-4"}],"isExternal":true},"3c44cba8-11":{"id":"@tsparticles/engine","moduleParts":{},"imported":[],"importedBy":[{"uid":"3c44cba8-4"},{"uid":"3c44cba8-0"}],"isExternal":true}},"env":{"rollup":"4.62.2"},"options":{"gzip":false,"brotli":false,"sourcemap":false}};
|
|
4934
4934
|
|
|
4935
4935
|
const run = () => {
|
|
4936
4936
|
const width = window.innerWidth;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
|
|
2
|
-
/* External Interaction v4.
|
|
2
|
+
/* External Interaction v4.3.0 */
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tsparticles/plugin-interactivity'), require('@tsparticles/engine')) :
|
|
5
5
|
typeof define === 'function' && define.amd ? define(['exports', '@tsparticles/plugin-interactivity', '@tsparticles/engine'], factory) :
|
|
@@ -18,9 +18,17 @@
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
class SlowModifier {
|
|
22
|
+
enabled = false;
|
|
23
|
+
id = "slow";
|
|
24
|
+
priority = 100;
|
|
25
|
+
speedFactor = 1;
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
const slowMode = "slow", minRadius = 0;
|
|
22
29
|
class Slower extends pluginInteractivity.ExternalInteractorBase {
|
|
23
30
|
#maxDistance;
|
|
31
|
+
#modifiers = new WeakMap();
|
|
24
32
|
constructor(container) {
|
|
25
33
|
super(container);
|
|
26
34
|
this.#maxDistance = 0;
|
|
@@ -29,10 +37,21 @@
|
|
|
29
37
|
return this.#maxDistance;
|
|
30
38
|
}
|
|
31
39
|
clear(particle, _delta, force) {
|
|
32
|
-
|
|
40
|
+
const mod = this.#modifiers.get(particle);
|
|
41
|
+
if (mod?.enabled && !force) {
|
|
33
42
|
return;
|
|
34
43
|
}
|
|
35
|
-
particle.
|
|
44
|
+
particle.removeModifier(slowMode);
|
|
45
|
+
this.#modifiers.delete(particle);
|
|
46
|
+
}
|
|
47
|
+
getOrCreateModifier(particle) {
|
|
48
|
+
let mod = this.#modifiers.get(particle);
|
|
49
|
+
if (!mod) {
|
|
50
|
+
mod = new SlowModifier();
|
|
51
|
+
this.#modifiers.set(particle, mod);
|
|
52
|
+
particle.addModifier(mod);
|
|
53
|
+
}
|
|
54
|
+
return mod;
|
|
36
55
|
}
|
|
37
56
|
init() {
|
|
38
57
|
const container = this.container, slow = container.actualOptions.interactivity?.modes.slow;
|
|
@@ -52,22 +71,26 @@
|
|
|
52
71
|
engine.loadOptionProperty(options, "slow", Slow, ...sources);
|
|
53
72
|
}
|
|
54
73
|
reset(interactivityData, particle) {
|
|
55
|
-
|
|
74
|
+
const mod = this.#modifiers.get(particle);
|
|
75
|
+
if (mod) {
|
|
76
|
+
mod.enabled = false;
|
|
77
|
+
}
|
|
56
78
|
const container = this.container, options = container.actualOptions, mousePos = interactivityData.mouse.position, radius = container.retina.slowModeRadius, slowOptions = options.interactivity?.modes.slow;
|
|
57
79
|
if (!slowOptions || !radius || radius < minRadius || !mousePos) {
|
|
58
80
|
return;
|
|
59
81
|
}
|
|
60
|
-
const particlePos = particle.getPosition(), dist = engine.getDistance(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slowOptions.factor
|
|
82
|
+
const particlePos = particle.getPosition(), dist = engine.getDistance(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slowOptions.factor;
|
|
61
83
|
if (dist > radius) {
|
|
62
84
|
return;
|
|
63
85
|
}
|
|
64
|
-
|
|
65
|
-
|
|
86
|
+
const activeMod = this.getOrCreateModifier(particle);
|
|
87
|
+
activeMod.enabled = true;
|
|
88
|
+
activeMod.speedFactor = proximityFactor / slowFactor;
|
|
66
89
|
}
|
|
67
90
|
}
|
|
68
91
|
|
|
69
92
|
async function loadExternalSlowInteraction(engine) {
|
|
70
|
-
engine.checkVersion("4.
|
|
93
|
+
engine.checkVersion("4.3.0");
|
|
71
94
|
await engine.pluginManager.register((e) => {
|
|
72
95
|
pluginInteractivity.ensureInteractivityPluginLoaded(e);
|
|
73
96
|
e.pluginManager.addInteractor?.("externalSlow", container => {
|
|
@@ -81,6 +104,7 @@
|
|
|
81
104
|
globalObject.loadExternalSlowInteraction = loadExternalSlowInteraction;
|
|
82
105
|
|
|
83
106
|
exports.Slow = Slow;
|
|
107
|
+
exports.SlowModifier = SlowModifier;
|
|
84
108
|
exports.loadExternalSlowInteraction = loadExternalSlowInteraction;
|
|
85
109
|
|
|
86
110
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t){t.__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.engine=t.__tsParticlesInternals.engine||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.palettes=t.__tsParticlesInternals.palettes||{},t.__tsParticlesInternals.paths=t.__tsParticlesInternals.paths||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins.emittersShapes=t.__tsParticlesInternals.plugins.emittersShapes||{},t.__tsParticlesInternals.presets=t.__tsParticlesInternals.presets||{},t.__tsParticlesInternals.shapes=t.__tsParticlesInternals.shapes||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.utils=t.__tsParticlesInternals.utils||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas.utils=t.__tsParticlesInternals.canvas.utils||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path.utils=t.__tsParticlesInternals.path.utils||{};var s="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,s){return s in t||(t[s]={}),t[s]}})}:function(t){return t};t.__tsParticlesInternals.bundles=s(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=s(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=s(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=s(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=s(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=s(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=s(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=s(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=s(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=s(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=s(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=s(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=s(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/plugin-interactivity","@tsparticles/engine"],s):s(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.interactions.externalSlow=t.__tsParticlesInternals.interactions.externalSlow||{}),t.__tsParticlesInternals.plugins.interactivity,t.__tsParticlesInternals.engine)}(this,function(t,s,e){"use strict";class n{factor=3;radius=200;load(t){e.isNull(t)||(e.loadProperty(this,"factor",t.factor),e.loadProperty(this,"radius",t.radius))}}class a extends s.ExternalInteractorBase{#t;constructor(t){super(t),this.#t=0}get maxDistance(){return this.#t}clear(t,s,e){t
|
|
1
|
+
!function(t){t.__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.engine=t.__tsParticlesInternals.engine||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.palettes=t.__tsParticlesInternals.palettes||{},t.__tsParticlesInternals.paths=t.__tsParticlesInternals.paths||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins.emittersShapes=t.__tsParticlesInternals.plugins.emittersShapes||{},t.__tsParticlesInternals.presets=t.__tsParticlesInternals.presets||{},t.__tsParticlesInternals.shapes=t.__tsParticlesInternals.shapes||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.utils=t.__tsParticlesInternals.utils||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas.utils=t.__tsParticlesInternals.canvas.utils||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path.utils=t.__tsParticlesInternals.path.utils||{};var s="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,s){return s in t||(t[s]={}),t[s]}})}:function(t){return t};t.__tsParticlesInternals.bundles=s(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=s(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=s(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=s(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=s(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=s(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=s(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=s(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=s(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=s(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=s(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=s(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=s(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/plugin-interactivity","@tsparticles/engine"],s):s(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.interactions.externalSlow=t.__tsParticlesInternals.interactions.externalSlow||{}),t.__tsParticlesInternals.plugins.interactivity,t.__tsParticlesInternals.engine)}(this,function(t,s,e){"use strict";class n{factor=3;radius=200;load(t){e.isNull(t)||(e.loadProperty(this,"factor",t.factor),e.loadProperty(this,"radius",t.radius))}}class a{enabled=!1;id="slow";priority=100;speedFactor=1}const r="slow";class i extends s.ExternalInteractorBase{#t;#s=new WeakMap;constructor(t){super(t),this.#t=0}get maxDistance(){return this.#t}clear(t,s,e){const n=this.#s.get(t);n?.enabled&&!e||(t.removeModifier(r),this.#s.delete(t))}getOrCreateModifier(t){let s=this.#s.get(t);return s||(s=new a,this.#s.set(t,s),t.addModifier(s)),s}init(){const t=this.container,s=t.actualOptions.interactivity?.modes.slow;s&&(this.#t=s.radius,t.retina.slowModeRadius=s.radius*t.retina.pixelRatio)}interact(){}isEnabled(t,s){const n=this.container,a=t.mouse,i=(s?.interactivity??n.actualOptions.interactivity)?.events;return!!i?.onHover.enable&&!!a.position&&e.isInArray(r,i.onHover.mode)}loadModeOptions(t,...s){e.loadOptionProperty(t,"slow",n,...s)}reset(t,s){const n=this.#s.get(s);n&&(n.enabled=!1);const a=this.container,r=a.actualOptions,i=t.mouse.position,l=a.retina.slowModeRadius,c=r.interactivity?.modes.slow;if(!c||!l||l<0||!i)return;const _=s.getPosition(),o=e.getDistance(i,_),I=o/l,P=c.factor;if(o>l)return;const p=this.getOrCreateModifier(s);p.enabled=!0,p.speedFactor=I/P}}async function l(t){t.checkVersion("4.3.0"),await t.pluginManager.register(t=>{s.ensureInteractivityPluginLoaded(t),t.pluginManager.addInteractor?.("externalSlow",t=>Promise.resolve(new i(t)))})}const c=globalThis;c.__tsParticlesInternals=c.__tsParticlesInternals??{},c.loadExternalSlowInteraction=l,t.Slow=n,t.SlowModifier=a,t.loadExternalSlowInteraction=l}),Object.assign(globalThis.window||globalThis,{loadExternalSlowInteraction:(globalThis.__tsParticlesInternals.interactions.externalSlow||{}).loadExternalSlowInteraction}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
|
package/types/Slower.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ExternalInteractorBase, type IInteractivityData, type IModes, type InteractivityParticle, type Modes } from "@tsparticles/plugin-interactivity";
|
|
2
2
|
import { type IDelta, type Particle, type RecursivePartial } from "@tsparticles/engine";
|
|
3
3
|
import type { ISlowMode, SlowContainer, SlowMode } from "./Types.js";
|
|
4
|
+
import { SlowModifier } from "./SlowModifier.js";
|
|
4
5
|
export declare class Slower extends ExternalInteractorBase<SlowContainer> {
|
|
5
6
|
#private;
|
|
6
7
|
constructor(container: SlowContainer);
|
|
7
8
|
get maxDistance(): number;
|
|
8
9
|
clear(particle: Particle, _delta: IDelta, force?: boolean): void;
|
|
10
|
+
getOrCreateModifier(particle: Particle): SlowModifier;
|
|
9
11
|
init(): void;
|
|
10
12
|
interact(): void;
|
|
11
13
|
isEnabled(interactivityData: IInteractivityData, particle?: InteractivityParticle): boolean;
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Engine } from "@tsparticles/engine";
|
|
2
2
|
export declare function loadExternalSlowInteraction(engine: Engine): Promise<void>;
|
|
3
|
+
export * from "./SlowModifier.js";
|
|
3
4
|
export * from "./Options/Classes/Slow.js";
|
|
4
5
|
export type * from "./Options/Interfaces/ISlow.js";
|