@tsparticles/interaction-particles-repulse 4.1.2 → 4.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.
@@ -1,37 +1,19 @@
1
- import { ValueWithRandom, isNull, setRangeValue, } from "@tsparticles/engine";
1
+ import { ValueWithRandom, isNull, loadProperty, loadRangeProperty, } from "@tsparticles/engine";
2
2
  export class ParticlesRepulse extends ValueWithRandom {
3
- distance;
4
- duration;
5
- enabled;
6
- factor;
7
- speed;
8
- constructor() {
9
- super();
10
- this.enabled = false;
11
- this.distance = 1;
12
- this.duration = 1;
13
- this.factor = 1;
14
- this.speed = 1;
15
- }
3
+ distance = 1;
4
+ duration = 1;
5
+ enabled = false;
6
+ factor = 1;
7
+ speed = 1;
16
8
  load(data) {
17
9
  super.load(data);
18
10
  if (isNull(data)) {
19
11
  return;
20
12
  }
21
- if (data.enabled !== undefined) {
22
- this.enabled = data.enabled;
23
- }
24
- if (data.distance !== undefined) {
25
- this.distance = setRangeValue(data.distance);
26
- }
27
- if (data.duration !== undefined) {
28
- this.duration = setRangeValue(data.duration);
29
- }
30
- if (data.factor !== undefined) {
31
- this.factor = setRangeValue(data.factor);
32
- }
33
- if (data.speed !== undefined) {
34
- this.speed = setRangeValue(data.speed);
35
- }
13
+ loadProperty(this, "enabled", data.enabled);
14
+ loadRangeProperty(this, "distance", data.distance);
15
+ loadRangeProperty(this, "duration", data.duration);
16
+ loadRangeProperty(this, "factor", data.factor);
17
+ loadRangeProperty(this, "speed", data.speed);
36
18
  }
37
19
  }
@@ -1,7 +1,6 @@
1
1
  import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
2
- import { Vector, clamp, getDistances, getRangeValue } from "@tsparticles/engine";
2
+ import { Vector, clamp, getDistances, getRangeValue, identity, loadOptionProperty, minDistance, minVelocity, squareExp, } from "@tsparticles/engine";
3
3
  import { ParticlesRepulse } from "./Options/Classes/ParticlesRepulse.js";
4
- const minDistance = 0, identity = 1, squareExp = 2, minVelocity = 0;
5
4
  export class Repulser extends ParticlesInteractorBase {
6
5
  #maxDistance;
7
6
  #normVec;
@@ -60,10 +59,7 @@ export class Repulser extends ParticlesInteractorBase {
60
59
  return particle.options.repulse?.enabled ?? false;
61
60
  }
62
61
  loadParticlesOptions(options, ...sources) {
63
- options.repulse ??= new ParticlesRepulse();
64
- for (const source of sources) {
65
- options.repulse.load(source?.repulse);
66
- }
62
+ loadOptionProperty(options, "repulse", ParticlesRepulse, ...sources);
67
63
  }
68
64
  reset() {
69
65
  }
package/browser/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ensureInteractivityPluginLoaded } from "@tsparticles/plugin-interactivity";
2
2
  import { Repulser } from "./Repulser.js";
3
3
  export async function loadParticlesRepulseInteraction(engine) {
4
- engine.checkVersion("4.1.2");
4
+ engine.checkVersion("4.2.0");
5
5
  await engine.pluginManager.register((e) => {
6
6
  ensureInteractivityPluginLoaded(e);
7
7
  e.pluginManager.addInteractor?.("particlesRepulse", container => {
@@ -1,5 +1,5 @@
1
1
  export async function loadParticlesRepulseInteraction(engine) {
2
- engine.checkVersion("4.1.2");
2
+ engine.checkVersion("4.2.0");
3
3
  await engine.pluginManager.register(async (e) => {
4
4
  const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity/lazy");
5
5
  ensureInteractivityPluginLoaded(e);
@@ -1,37 +1,19 @@
1
- import { ValueWithRandom, isNull, setRangeValue, } from "@tsparticles/engine";
1
+ import { ValueWithRandom, isNull, loadProperty, loadRangeProperty, } from "@tsparticles/engine";
2
2
  export class ParticlesRepulse extends ValueWithRandom {
3
- distance;
4
- duration;
5
- enabled;
6
- factor;
7
- speed;
8
- constructor() {
9
- super();
10
- this.enabled = false;
11
- this.distance = 1;
12
- this.duration = 1;
13
- this.factor = 1;
14
- this.speed = 1;
15
- }
3
+ distance = 1;
4
+ duration = 1;
5
+ enabled = false;
6
+ factor = 1;
7
+ speed = 1;
16
8
  load(data) {
17
9
  super.load(data);
18
10
  if (isNull(data)) {
19
11
  return;
20
12
  }
21
- if (data.enabled !== undefined) {
22
- this.enabled = data.enabled;
23
- }
24
- if (data.distance !== undefined) {
25
- this.distance = setRangeValue(data.distance);
26
- }
27
- if (data.duration !== undefined) {
28
- this.duration = setRangeValue(data.duration);
29
- }
30
- if (data.factor !== undefined) {
31
- this.factor = setRangeValue(data.factor);
32
- }
33
- if (data.speed !== undefined) {
34
- this.speed = setRangeValue(data.speed);
35
- }
13
+ loadProperty(this, "enabled", data.enabled);
14
+ loadRangeProperty(this, "distance", data.distance);
15
+ loadRangeProperty(this, "duration", data.duration);
16
+ loadRangeProperty(this, "factor", data.factor);
17
+ loadRangeProperty(this, "speed", data.speed);
36
18
  }
37
19
  }
package/cjs/Repulser.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
2
- import { Vector, clamp, getDistances, getRangeValue } from "@tsparticles/engine";
2
+ import { Vector, clamp, getDistances, getRangeValue, identity, loadOptionProperty, minDistance, minVelocity, squareExp, } from "@tsparticles/engine";
3
3
  import { ParticlesRepulse } from "./Options/Classes/ParticlesRepulse.js";
4
- const minDistance = 0, identity = 1, squareExp = 2, minVelocity = 0;
5
4
  export class Repulser extends ParticlesInteractorBase {
6
5
  #maxDistance;
7
6
  #normVec;
@@ -60,10 +59,7 @@ export class Repulser extends ParticlesInteractorBase {
60
59
  return particle.options.repulse?.enabled ?? false;
61
60
  }
62
61
  loadParticlesOptions(options, ...sources) {
63
- options.repulse ??= new ParticlesRepulse();
64
- for (const source of sources) {
65
- options.repulse.load(source?.repulse);
66
- }
62
+ loadOptionProperty(options, "repulse", ParticlesRepulse, ...sources);
67
63
  }
68
64
  reset() {
69
65
  }
package/cjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ensureInteractivityPluginLoaded } from "@tsparticles/plugin-interactivity";
2
2
  import { Repulser } from "./Repulser.js";
3
3
  export async function loadParticlesRepulseInteraction(engine) {
4
- engine.checkVersion("4.1.2");
4
+ engine.checkVersion("4.2.0");
5
5
  await engine.pluginManager.register((e) => {
6
6
  ensureInteractivityPluginLoaded(e);
7
7
  e.pluginManager.addInteractor?.("particlesRepulse", container => {
package/cjs/index.lazy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export async function loadParticlesRepulseInteraction(engine) {
2
- engine.checkVersion("4.1.2");
2
+ engine.checkVersion("4.2.0");
3
3
  await engine.pluginManager.register(async (e) => {
4
4
  const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity/lazy");
5
5
  ensureInteractivityPluginLoaded(e);
@@ -1,37 +1,19 @@
1
- import { ValueWithRandom, isNull, setRangeValue, } from "@tsparticles/engine";
1
+ import { ValueWithRandom, isNull, loadProperty, loadRangeProperty, } from "@tsparticles/engine";
2
2
  export class ParticlesRepulse extends ValueWithRandom {
3
- distance;
4
- duration;
5
- enabled;
6
- factor;
7
- speed;
8
- constructor() {
9
- super();
10
- this.enabled = false;
11
- this.distance = 1;
12
- this.duration = 1;
13
- this.factor = 1;
14
- this.speed = 1;
15
- }
3
+ distance = 1;
4
+ duration = 1;
5
+ enabled = false;
6
+ factor = 1;
7
+ speed = 1;
16
8
  load(data) {
17
9
  super.load(data);
18
10
  if (isNull(data)) {
19
11
  return;
20
12
  }
21
- if (data.enabled !== undefined) {
22
- this.enabled = data.enabled;
23
- }
24
- if (data.distance !== undefined) {
25
- this.distance = setRangeValue(data.distance);
26
- }
27
- if (data.duration !== undefined) {
28
- this.duration = setRangeValue(data.duration);
29
- }
30
- if (data.factor !== undefined) {
31
- this.factor = setRangeValue(data.factor);
32
- }
33
- if (data.speed !== undefined) {
34
- this.speed = setRangeValue(data.speed);
35
- }
13
+ loadProperty(this, "enabled", data.enabled);
14
+ loadRangeProperty(this, "distance", data.distance);
15
+ loadRangeProperty(this, "duration", data.duration);
16
+ loadRangeProperty(this, "factor", data.factor);
17
+ loadRangeProperty(this, "speed", data.speed);
36
18
  }
37
19
  }
package/esm/Repulser.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
2
- import { Vector, clamp, getDistances, getRangeValue } from "@tsparticles/engine";
2
+ import { Vector, clamp, getDistances, getRangeValue, identity, loadOptionProperty, minDistance, minVelocity, squareExp, } from "@tsparticles/engine";
3
3
  import { ParticlesRepulse } from "./Options/Classes/ParticlesRepulse.js";
4
- const minDistance = 0, identity = 1, squareExp = 2, minVelocity = 0;
5
4
  export class Repulser extends ParticlesInteractorBase {
6
5
  #maxDistance;
7
6
  #normVec;
@@ -60,10 +59,7 @@ export class Repulser extends ParticlesInteractorBase {
60
59
  return particle.options.repulse?.enabled ?? false;
61
60
  }
62
61
  loadParticlesOptions(options, ...sources) {
63
- options.repulse ??= new ParticlesRepulse();
64
- for (const source of sources) {
65
- options.repulse.load(source?.repulse);
66
- }
62
+ loadOptionProperty(options, "repulse", ParticlesRepulse, ...sources);
67
63
  }
68
64
  reset() {
69
65
  }
package/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ensureInteractivityPluginLoaded } from "@tsparticles/plugin-interactivity";
2
2
  import { Repulser } from "./Repulser.js";
3
3
  export async function loadParticlesRepulseInteraction(engine) {
4
- engine.checkVersion("4.1.2");
4
+ engine.checkVersion("4.2.0");
5
5
  await engine.pluginManager.register((e) => {
6
6
  ensureInteractivityPluginLoaded(e);
7
7
  e.pluginManager.addInteractor?.("particlesRepulse", container => {
package/esm/index.lazy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export async function loadParticlesRepulseInteraction(engine) {
2
- engine.checkVersion("4.1.2");
2
+ engine.checkVersion("4.2.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-particles-repulse",
3
- "version": "4.1.2",
3
+ "version": "4.2.0",
4
4
  "description": "tsParticles repulse particles interaction",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -107,8 +107,8 @@
107
107
  "./package.json": "./package.json"
108
108
  },
109
109
  "peerDependencies": {
110
- "@tsparticles/engine": "4.1.2",
111
- "@tsparticles/plugin-interactivity": "4.1.2"
110
+ "@tsparticles/engine": "4.2.0",
111
+ "@tsparticles/plugin-interactivity": "4.2.0"
112
112
  },
113
113
  "publishConfig": {
114
114
  "access": "public"
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.particles.repulse.js","children":[{"name":"dist/browser","children":[{"name":"Options/Classes/ParticlesRepulse.js","uid":"2bbc2f5c-1"},{"uid":"2bbc2f5c-3","name":"Repulser.js"},{"uid":"2bbc2f5c-5","name":"index.js"},{"uid":"2bbc2f5c-7","name":"browser.js"}]}]}],"isRoot":true},"nodeParts":{"2bbc2f5c-1":{"renderedLength":1105,"gzipLength":0,"brotliLength":0,"metaUid":"2bbc2f5c-0"},"2bbc2f5c-3":{"renderedLength":2799,"gzipLength":0,"brotliLength":0,"metaUid":"2bbc2f5c-2"},"2bbc2f5c-5":{"renderedLength":397,"gzipLength":0,"brotliLength":0,"metaUid":"2bbc2f5c-4"},"2bbc2f5c-7":{"renderedLength":205,"gzipLength":0,"brotliLength":0,"metaUid":"2bbc2f5c-6"}},"nodeMetas":{"2bbc2f5c-0":{"id":"/dist/browser/Options/Classes/ParticlesRepulse.js","moduleParts":{"tsparticles.interaction.particles.repulse.js":"2bbc2f5c-1"},"imported":[{"uid":"2bbc2f5c-9"}],"importedBy":[{"uid":"2bbc2f5c-2"}]},"2bbc2f5c-2":{"id":"/dist/browser/Repulser.js","moduleParts":{"tsparticles.interaction.particles.repulse.js":"2bbc2f5c-3"},"imported":[{"uid":"2bbc2f5c-8"},{"uid":"2bbc2f5c-9"},{"uid":"2bbc2f5c-0"}],"importedBy":[{"uid":"2bbc2f5c-4"}]},"2bbc2f5c-4":{"id":"/dist/browser/index.js","moduleParts":{"tsparticles.interaction.particles.repulse.js":"2bbc2f5c-5"},"imported":[{"uid":"2bbc2f5c-8"},{"uid":"2bbc2f5c-2"}],"importedBy":[{"uid":"2bbc2f5c-6"}]},"2bbc2f5c-6":{"id":"/dist/browser/browser.js","moduleParts":{"tsparticles.interaction.particles.repulse.js":"2bbc2f5c-7"},"imported":[{"uid":"2bbc2f5c-4"}],"importedBy":[],"isEntry":true},"2bbc2f5c-8":{"id":"@tsparticles/plugin-interactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"2bbc2f5c-4"},{"uid":"2bbc2f5c-2"}],"isExternal":true},"2bbc2f5c-9":{"id":"@tsparticles/engine","moduleParts":{},"imported":[],"importedBy":[{"uid":"2bbc2f5c-2"},{"uid":"2bbc2f5c-0"}],"isExternal":true}},"env":{"rollup":"4.60.4"},"options":{"gzip":false,"brotli":false,"sourcemap":false}};
4933
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"tsparticles.interaction.particles.repulse.js","children":[{"name":"dist/browser","children":[{"name":"Options/Classes/ParticlesRepulse.js","uid":"fdc12341-1"},{"uid":"fdc12341-3","name":"Repulser.js"},{"uid":"fdc12341-5","name":"index.js"},{"uid":"fdc12341-7","name":"browser.js"}]}]}],"isRoot":true},"nodeParts":{"fdc12341-1":{"renderedLength":649,"gzipLength":0,"brotliLength":0,"metaUid":"fdc12341-0"},"fdc12341-3":{"renderedLength":2688,"gzipLength":0,"brotliLength":0,"metaUid":"fdc12341-2"},"fdc12341-5":{"renderedLength":397,"gzipLength":0,"brotliLength":0,"metaUid":"fdc12341-4"},"fdc12341-7":{"renderedLength":205,"gzipLength":0,"brotliLength":0,"metaUid":"fdc12341-6"}},"nodeMetas":{"fdc12341-0":{"id":"/dist/browser/Options/Classes/ParticlesRepulse.js","moduleParts":{"tsparticles.interaction.particles.repulse.js":"fdc12341-1"},"imported":[{"uid":"fdc12341-9"}],"importedBy":[{"uid":"fdc12341-2"}]},"fdc12341-2":{"id":"/dist/browser/Repulser.js","moduleParts":{"tsparticles.interaction.particles.repulse.js":"fdc12341-3"},"imported":[{"uid":"fdc12341-8"},{"uid":"fdc12341-9"},{"uid":"fdc12341-0"}],"importedBy":[{"uid":"fdc12341-4"}]},"fdc12341-4":{"id":"/dist/browser/index.js","moduleParts":{"tsparticles.interaction.particles.repulse.js":"fdc12341-5"},"imported":[{"uid":"fdc12341-8"},{"uid":"fdc12341-2"}],"importedBy":[{"uid":"fdc12341-6"}]},"fdc12341-6":{"id":"/dist/browser/browser.js","moduleParts":{"tsparticles.interaction.particles.repulse.js":"fdc12341-7"},"imported":[{"uid":"fdc12341-4"}],"importedBy":[],"isEntry":true},"fdc12341-8":{"id":"@tsparticles/plugin-interactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"fdc12341-4"},{"uid":"fdc12341-2"}],"isExternal":true},"fdc12341-9":{"id":"@tsparticles/engine","moduleParts":{},"imported":[],"importedBy":[{"uid":"fdc12341-2"},{"uid":"fdc12341-0"}],"isExternal":true}},"env":{"rollup":"4.62.0"},"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
- /* Particles Interaction v4.1.2 */
2
+ /* Particles Interaction v4.2.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) :
@@ -7,43 +7,24 @@
7
7
  })(this, (function (exports, pluginInteractivity, engine) { 'use strict';
8
8
 
9
9
  class ParticlesRepulse extends engine.ValueWithRandom {
10
- distance;
11
- duration;
12
- enabled;
13
- factor;
14
- speed;
15
- constructor() {
16
- super();
17
- this.enabled = false;
18
- this.distance = 1;
19
- this.duration = 1;
20
- this.factor = 1;
21
- this.speed = 1;
22
- }
10
+ distance = 1;
11
+ duration = 1;
12
+ enabled = false;
13
+ factor = 1;
14
+ speed = 1;
23
15
  load(data) {
24
16
  super.load(data);
25
17
  if (engine.isNull(data)) {
26
18
  return;
27
19
  }
28
- if (data.enabled !== undefined) {
29
- this.enabled = data.enabled;
30
- }
31
- if (data.distance !== undefined) {
32
- this.distance = engine.setRangeValue(data.distance);
33
- }
34
- if (data.duration !== undefined) {
35
- this.duration = engine.setRangeValue(data.duration);
36
- }
37
- if (data.factor !== undefined) {
38
- this.factor = engine.setRangeValue(data.factor);
39
- }
40
- if (data.speed !== undefined) {
41
- this.speed = engine.setRangeValue(data.speed);
42
- }
20
+ engine.loadProperty(this, "enabled", data.enabled);
21
+ engine.loadRangeProperty(this, "distance", data.distance);
22
+ engine.loadRangeProperty(this, "duration", data.duration);
23
+ engine.loadRangeProperty(this, "factor", data.factor);
24
+ engine.loadRangeProperty(this, "speed", data.speed);
43
25
  }
44
26
  }
45
27
 
46
- const minDistance = 0, identity = 1, squareExp = 2, minVelocity = 0;
47
28
  class Repulser extends pluginInteractivity.ParticlesInteractorBase {
48
29
  #maxDistance;
49
30
  #normVec;
@@ -78,14 +59,14 @@
78
59
  factor: engine.getRangeValue(repulseOpt1.factor),
79
60
  };
80
61
  }
81
- const pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, p1.repulse.distance), p1DistanceFactor = identity / p1.repulse.distance;
62
+ const pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, p1.repulse.distance), p1DistanceFactor = engine.identity / p1.repulse.distance;
82
63
  for (const p2 of query) {
83
64
  if (p1 === p2 || p2.destroyed) {
84
65
  continue;
85
66
  }
86
- const pos2 = p2.getPosition(), { dx, dy, distance } = engine.getDistances(pos2, pos1), distanceFactor = identity / distance, velocity = p1.repulse.speed * p1.repulse.factor;
87
- if (distance > minDistance) {
88
- const repulseFactor = engine.clamp((identity - Math.pow(distance * p1DistanceFactor, squareExp)) * velocity, minVelocity, velocity) *
67
+ const pos2 = p2.getPosition(), { dx, dy, distance } = engine.getDistances(pos2, pos1), distanceFactor = engine.identity / distance, velocity = p1.repulse.speed * p1.repulse.factor;
68
+ if (distance > engine.minDistance) {
69
+ const repulseFactor = engine.clamp((engine.identity - Math.pow(distance * p1DistanceFactor, engine.squareExp)) * velocity, engine.minVelocity, velocity) *
89
70
  distanceFactor;
90
71
  this.#normVec.x = dx * repulseFactor;
91
72
  this.#normVec.y = dy * repulseFactor;
@@ -102,17 +83,14 @@
102
83
  return particle.options.repulse?.enabled ?? false;
103
84
  }
104
85
  loadParticlesOptions(options, ...sources) {
105
- options.repulse ??= new ParticlesRepulse();
106
- for (const source of sources) {
107
- options.repulse.load(source?.repulse);
108
- }
86
+ engine.loadOptionProperty(options, "repulse", ParticlesRepulse, ...sources);
109
87
  }
110
88
  reset() {
111
89
  }
112
90
  }
113
91
 
114
92
  async function loadParticlesRepulseInteraction(engine) {
115
- engine.checkVersion("4.1.2");
93
+ engine.checkVersion("4.2.0");
116
94
  await engine.pluginManager.register((e) => {
117
95
  pluginInteractivity.ensureInteractivityPluginLoaded(e);
118
96
  e.pluginManager.addInteractor?.("particlesRepulse", container => {
@@ -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.particlesRepulse=t.__tsParticlesInternals.interactions.particlesRepulse||{}),t.__tsParticlesInternals.plugins.interactivity,t.__tsParticlesInternals.engine)}(this,function(t,s,e){"use strict";class n extends e.ValueWithRandom{distance;duration;enabled;factor;speed;constructor(){super(),this.enabled=!1,this.distance=1,this.duration=1,this.factor=1,this.speed=1}load(t){super.load(t),e.isNull(t)||(void 0!==t.enabled&&(this.enabled=t.enabled),void 0!==t.distance&&(this.distance=e.setRangeValue(t.distance)),void 0!==t.duration&&(this.duration=e.setRangeValue(t.duration)),void 0!==t.factor&&(this.factor=e.setRangeValue(t.factor)),void 0!==t.speed&&(this.speed=e.setRangeValue(t.speed)))}}class a extends s.ParticlesInteractorBase{#t;#s;#e;constructor(t){super(t),this.#t=0,this.#s=e.Vector.origin,this.#e=e.Vector.origin}get maxDistance(){return this.#t}clear(){}init(){}interact(t){const s=this.container;if(!t.repulse){const n=t.options.repulse;if(!n)return;const a=e.getRangeValue(n.distance);a>this.maxDistance&&(this.#t=a),t.repulse={distance:a*s.retina.pixelRatio,speed:e.getRangeValue(n.speed),factor:e.getRangeValue(n.factor)}}const n=t.getPosition(),a=s.particles.grid.queryCircle(n,t.repulse.distance),r=1/t.repulse.distance;for(const s of a){if(t===s||s.destroyed)continue;const a=s.getPosition(),{dx:i,dy:l,distance:c}=e.getDistances(a,n),_=1/c,o=t.repulse.speed*t.repulse.factor;if(c>0){const t=e.clamp((1-Math.pow(c*r,2))*o,0,o)*_;this.#s.x=i*t,this.#s.y=l*t,s.position.addTo(this.#s)}else this.#e.x=o,this.#e.y=o,s.position.addTo(this.#e)}}isEnabled(t){return t.options.repulse?.enabled??!1}loadParticlesOptions(t,...s){t.repulse??=new n;for(const e of s)t.repulse.load(e?.repulse)}reset(){}}async function r(t){t.checkVersion("4.1.2"),await t.pluginManager.register(t=>{s.ensureInteractivityPluginLoaded(t),t.pluginManager.addInteractor?.("particlesRepulse",t=>Promise.resolve(new a(t)))})}const i=globalThis;i.__tsParticlesInternals=i.__tsParticlesInternals??{},i.loadParticlesRepulseInteraction=r,t.loadParticlesRepulseInteraction=r}),Object.assign(globalThis.window||globalThis,{loadParticlesRepulseInteraction:(globalThis.__tsParticlesInternals.interactions.particlesRepulse||{}).loadParticlesRepulseInteraction}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
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.particlesRepulse=t.__tsParticlesInternals.interactions.particlesRepulse||{}),t.__tsParticlesInternals.plugins.interactivity,t.__tsParticlesInternals.engine)}(this,function(t,s,e){"use strict";class n extends e.ValueWithRandom{distance=1;duration=1;enabled=!1;factor=1;speed=1;load(t){super.load(t),e.isNull(t)||(e.loadProperty(this,"enabled",t.enabled),e.loadRangeProperty(this,"distance",t.distance),e.loadRangeProperty(this,"duration",t.duration),e.loadRangeProperty(this,"factor",t.factor),e.loadRangeProperty(this,"speed",t.speed))}}class a extends s.ParticlesInteractorBase{#t;#s;#e;constructor(t){super(t),this.#t=0,this.#s=e.Vector.origin,this.#e=e.Vector.origin}get maxDistance(){return this.#t}clear(){}init(){}interact(t){const s=this.container;if(!t.repulse){const n=t.options.repulse;if(!n)return;const a=e.getRangeValue(n.distance);a>this.maxDistance&&(this.#t=a),t.repulse={distance:a*s.retina.pixelRatio,speed:e.getRangeValue(n.speed),factor:e.getRangeValue(n.factor)}}const n=t.getPosition(),a=s.particles.grid.queryCircle(n,t.repulse.distance),r=e.identity/t.repulse.distance;for(const s of a){if(t===s||s.destroyed)continue;const a=s.getPosition(),{dx:i,dy:l,distance:c}=e.getDistances(a,n),_=e.identity/c,o=t.repulse.speed*t.repulse.factor;if(c>e.minDistance){const t=e.clamp((e.identity-Math.pow(c*r,e.squareExp))*o,e.minVelocity,o)*_;this.#s.x=i*t,this.#s.y=l*t,s.position.addTo(this.#s)}else this.#e.x=o,this.#e.y=o,s.position.addTo(this.#e)}}isEnabled(t){return t.options.repulse?.enabled??!1}loadParticlesOptions(t,...s){e.loadOptionProperty(t,"repulse",n,...s)}reset(){}}async function r(t){t.checkVersion("4.2.0"),await t.pluginManager.register(t=>{s.ensureInteractivityPluginLoaded(t),t.pluginManager.addInteractor?.("particlesRepulse",t=>Promise.resolve(new a(t)))})}const i=globalThis;i.__tsParticlesInternals=i.__tsParticlesInternals??{},i.loadParticlesRepulseInteraction=r,t.loadParticlesRepulseInteraction=r}),Object.assign(globalThis.window||globalThis,{loadParticlesRepulseInteraction:(globalThis.__tsParticlesInternals.interactions.particlesRepulse||{}).loadParticlesRepulseInteraction}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
@@ -6,6 +6,5 @@ export declare class ParticlesRepulse extends ValueWithRandom implements IPartic
6
6
  enabled: boolean;
7
7
  factor: RangeValue;
8
8
  speed: RangeValue;
9
- constructor();
10
9
  load(data?: RecursivePartial<IParticlesRepulse>): void;
11
10
  }
@@ -17,6 +17,6 @@ export declare class Repulser extends ParticlesInteractorBase {
17
17
  init(): void;
18
18
  interact(p1: RepulseParticle): void;
19
19
  isEnabled(particle: RepulseParticle): boolean;
20
- loadParticlesOptions?(options: RepulseParticlesOptions, ...sources: (RecursivePartial<IRepulseParticlesOptions> | undefined)[]): void;
20
+ loadParticlesOptions(options: RepulseParticlesOptions, ...sources: (RecursivePartial<IRepulseParticlesOptions> | undefined)[]): void;
21
21
  reset(): void;
22
22
  }