@tsparticles/interaction-external-repulse 4.1.3 → 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,19 +1,13 @@
1
- import { EasingType, isNull } from "@tsparticles/engine";
1
+ import { isNull, loadProperty } from "@tsparticles/engine";
2
2
  export class RepulseBase {
3
- distance;
4
- duration;
5
- easing;
6
- factor;
7
- maxSpeed;
3
+ distance = 200;
4
+ duration = 0.4;
5
+ easing = "ease-out-quad";
6
+ factor = 100;
7
+ maxSpeed = 50;
8
8
  restore;
9
- speed;
9
+ speed = 1;
10
10
  constructor() {
11
- this.distance = 200;
12
- this.duration = 0.4;
13
- this.factor = 100;
14
- this.speed = 1;
15
- this.maxSpeed = 50;
16
- this.easing = EasingType.easeOutQuad;
17
11
  this.restore = {
18
12
  enable: false,
19
13
  delay: 0,
@@ -25,24 +19,12 @@ export class RepulseBase {
25
19
  if (isNull(data)) {
26
20
  return;
27
21
  }
28
- if (data.distance !== undefined) {
29
- this.distance = data.distance;
30
- }
31
- if (data.duration !== undefined) {
32
- this.duration = data.duration;
33
- }
34
- if (data.easing !== undefined) {
35
- this.easing = data.easing;
36
- }
37
- if (data.factor !== undefined) {
38
- this.factor = data.factor;
39
- }
40
- if (data.speed !== undefined) {
41
- this.speed = data.speed;
42
- }
43
- if (data.maxSpeed !== undefined) {
44
- this.maxSpeed = data.maxSpeed;
45
- }
22
+ loadProperty(this, "distance", data.distance);
23
+ loadProperty(this, "duration", data.duration);
24
+ loadProperty(this, "easing", data.easing);
25
+ loadProperty(this, "factor", data.factor);
26
+ loadProperty(this, "speed", data.speed);
27
+ loadProperty(this, "maxSpeed", data.maxSpeed);
46
28
  if (data.restore !== undefined) {
47
29
  this.restore.enable = data.restore.enable ?? this.restore.enable;
48
30
  this.restore.delay = data.restore.delay ?? this.restore.delay;
@@ -1,18 +1,12 @@
1
- import { isNull } from "@tsparticles/engine";
1
+ import { isNull, loadProperty, } from "@tsparticles/engine";
2
2
  import { RepulseBase } from "./RepulseBase.js";
3
3
  export class RepulseDiv extends RepulseBase {
4
- selectors;
5
- constructor() {
6
- super();
7
- this.selectors = [];
8
- }
4
+ selectors = [];
9
5
  load(data) {
10
6
  super.load(data);
11
7
  if (isNull(data)) {
12
8
  return;
13
9
  }
14
- if (data.selectors !== undefined) {
15
- this.selectors = data.selectors;
16
- }
10
+ loadProperty(this, "selectors", data.selectors);
17
11
  }
18
12
  }
@@ -1,4 +1,4 @@
1
- import { Circle, Rectangle, Vector, clamp, getDistances, half, isInArray, millisecondsToSeconds, safeDocument, } from "@tsparticles/engine";
1
+ import { Circle, Rectangle, Vector, clamp, getDistances, half, isInArray, loadOptionProperty, millisecondsToSeconds, safeDocument, } from "@tsparticles/engine";
2
2
  import { DivType, ExternalInteractorBase, divMode, divModeExecute, isDivModeEnabled, mouseMoveEvent, } from "@tsparticles/plugin-interactivity";
3
3
  import { Repulse } from "./Options/Classes/Repulse.js";
4
4
  const repulseMode = "repulse", minDistance = 0, repulseRadiusFactor = 6, repulseRadiusPower = 3, squarePower = 2, minRadius = 0, minSpeed = 0, easingOffset = 1, minRestoreSpeed = 0.001, maxRestoreSpeed = 1, restoreEpsilon = 0.5;
@@ -90,14 +90,11 @@ export class Repulser extends ExternalInteractorBase {
90
90
  return isInArray(repulseMode, hoverMode) || isInArray(repulseMode, clickMode) || divRepulse;
91
91
  }
92
92
  loadModeOptions(options, ...sources) {
93
- options.repulse ??= new Repulse();
94
- for (const source of sources) {
95
- options.repulse.load(source?.repulse);
96
- }
93
+ loadOptionProperty(options, "repulse", Repulse, ...sources);
97
94
  }
98
95
  reset() {
99
96
  }
100
- #clickRepulse = interactivityData => {
97
+ #clickRepulse(interactivityData) {
101
98
  const container = this.container, repulseOptions = container.actualOptions.interactivity?.modes.repulse;
102
99
  if (!repulseOptions) {
103
100
  return;
@@ -138,15 +135,15 @@ export class Repulser extends ExternalInteractorBase {
138
135
  }
139
136
  repulse.particles = [];
140
137
  }
141
- };
142
- #hoverRepulse = interactivityData => {
138
+ }
139
+ #hoverRepulse(interactivityData) {
143
140
  const container = this.container, mousePos = interactivityData.mouse.position, repulseRadius = container.retina.repulseModeDistance;
144
141
  if (!repulseRadius || repulseRadius < minRadius || !mousePos) {
145
142
  return;
146
143
  }
147
144
  this.#processRepulse(interactivityData, mousePos, repulseRadius, new Circle(mousePos.x, mousePos.y, repulseRadius));
148
- };
149
- #processRepulse = (interactivityData, position, repulseRadius, area, divRepulse) => {
145
+ }
146
+ #processRepulse(interactivityData, position, repulseRadius, area, divRepulse) {
150
147
  const container = this.container, query = container.particles.grid.query(area, p => this.isEnabled(interactivityData, p)), repulseOptions = container.actualOptions.interactivity?.modes.repulse;
151
148
  if (!repulseOptions) {
152
149
  return;
@@ -159,7 +156,7 @@ export class Repulser extends ExternalInteractorBase {
159
156
  this.#trackInteractedParticle(particle);
160
157
  particle.position.addTo(this.#normVec);
161
158
  }
162
- };
159
+ }
163
160
  #restoreParticles() {
164
161
  const restore = this.container.actualOptions.interactivity?.modes.repulse?.restore;
165
162
  if (!restore?.enable || !this.#restoreData.size) {
@@ -196,7 +193,7 @@ export class Repulser extends ExternalInteractorBase {
196
193
  }
197
194
  }
198
195
  }
199
- #singleSelectorRepulse = (interactivityData, selector, div) => {
196
+ #singleSelectorRepulse(interactivityData, selector, div) {
200
197
  const container = this.container, repulse = container.actualOptions.interactivity?.modes.repulse;
201
198
  if (!repulse) {
202
199
  return;
@@ -214,7 +211,7 @@ export class Repulser extends ExternalInteractorBase {
214
211
  : new Rectangle(elem.offsetLeft * pxRatio, elem.offsetTop * pxRatio, elem.offsetWidth * pxRatio, elem.offsetHeight * pxRatio), divs = repulse.divs, divRepulse = divMode(divs, elem);
215
212
  this.#processRepulse(interactivityData, pos, repulseRadius, area, divRepulse);
216
213
  });
217
- };
214
+ }
218
215
  #trackInteractedParticle(particle) {
219
216
  this.#interactedThisFrame.add(particle);
220
217
  const restore = this.container.actualOptions.interactivity?.modes.repulse?.restore;
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 loadExternalRepulseInteraction(engine) {
4
- engine.checkVersion("4.1.3");
4
+ engine.checkVersion("4.2.0");
5
5
  await engine.pluginManager.register((e) => {
6
6
  ensureInteractivityPluginLoaded(e);
7
7
  const pluginManager = e.pluginManager;
@@ -1,5 +1,5 @@
1
1
  export async function loadExternalRepulseInteraction(engine) {
2
- engine.checkVersion("4.1.3");
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,19 +1,13 @@
1
- import { EasingType, isNull } from "@tsparticles/engine";
1
+ import { isNull, loadProperty } from "@tsparticles/engine";
2
2
  export class RepulseBase {
3
- distance;
4
- duration;
5
- easing;
6
- factor;
7
- maxSpeed;
3
+ distance = 200;
4
+ duration = 0.4;
5
+ easing = "ease-out-quad";
6
+ factor = 100;
7
+ maxSpeed = 50;
8
8
  restore;
9
- speed;
9
+ speed = 1;
10
10
  constructor() {
11
- this.distance = 200;
12
- this.duration = 0.4;
13
- this.factor = 100;
14
- this.speed = 1;
15
- this.maxSpeed = 50;
16
- this.easing = EasingType.easeOutQuad;
17
11
  this.restore = {
18
12
  enable: false,
19
13
  delay: 0,
@@ -25,24 +19,12 @@ export class RepulseBase {
25
19
  if (isNull(data)) {
26
20
  return;
27
21
  }
28
- if (data.distance !== undefined) {
29
- this.distance = data.distance;
30
- }
31
- if (data.duration !== undefined) {
32
- this.duration = data.duration;
33
- }
34
- if (data.easing !== undefined) {
35
- this.easing = data.easing;
36
- }
37
- if (data.factor !== undefined) {
38
- this.factor = data.factor;
39
- }
40
- if (data.speed !== undefined) {
41
- this.speed = data.speed;
42
- }
43
- if (data.maxSpeed !== undefined) {
44
- this.maxSpeed = data.maxSpeed;
45
- }
22
+ loadProperty(this, "distance", data.distance);
23
+ loadProperty(this, "duration", data.duration);
24
+ loadProperty(this, "easing", data.easing);
25
+ loadProperty(this, "factor", data.factor);
26
+ loadProperty(this, "speed", data.speed);
27
+ loadProperty(this, "maxSpeed", data.maxSpeed);
46
28
  if (data.restore !== undefined) {
47
29
  this.restore.enable = data.restore.enable ?? this.restore.enable;
48
30
  this.restore.delay = data.restore.delay ?? this.restore.delay;
@@ -1,18 +1,12 @@
1
- import { isNull } from "@tsparticles/engine";
1
+ import { isNull, loadProperty, } from "@tsparticles/engine";
2
2
  import { RepulseBase } from "./RepulseBase.js";
3
3
  export class RepulseDiv extends RepulseBase {
4
- selectors;
5
- constructor() {
6
- super();
7
- this.selectors = [];
8
- }
4
+ selectors = [];
9
5
  load(data) {
10
6
  super.load(data);
11
7
  if (isNull(data)) {
12
8
  return;
13
9
  }
14
- if (data.selectors !== undefined) {
15
- this.selectors = data.selectors;
16
- }
10
+ loadProperty(this, "selectors", data.selectors);
17
11
  }
18
12
  }
package/cjs/Repulser.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Circle, Rectangle, Vector, clamp, getDistances, half, isInArray, millisecondsToSeconds, safeDocument, } from "@tsparticles/engine";
1
+ import { Circle, Rectangle, Vector, clamp, getDistances, half, isInArray, loadOptionProperty, millisecondsToSeconds, safeDocument, } from "@tsparticles/engine";
2
2
  import { DivType, ExternalInteractorBase, divMode, divModeExecute, isDivModeEnabled, mouseMoveEvent, } from "@tsparticles/plugin-interactivity";
3
3
  import { Repulse } from "./Options/Classes/Repulse.js";
4
4
  const repulseMode = "repulse", minDistance = 0, repulseRadiusFactor = 6, repulseRadiusPower = 3, squarePower = 2, minRadius = 0, minSpeed = 0, easingOffset = 1, minRestoreSpeed = 0.001, maxRestoreSpeed = 1, restoreEpsilon = 0.5;
@@ -90,14 +90,11 @@ export class Repulser extends ExternalInteractorBase {
90
90
  return isInArray(repulseMode, hoverMode) || isInArray(repulseMode, clickMode) || divRepulse;
91
91
  }
92
92
  loadModeOptions(options, ...sources) {
93
- options.repulse ??= new Repulse();
94
- for (const source of sources) {
95
- options.repulse.load(source?.repulse);
96
- }
93
+ loadOptionProperty(options, "repulse", Repulse, ...sources);
97
94
  }
98
95
  reset() {
99
96
  }
100
- #clickRepulse = interactivityData => {
97
+ #clickRepulse(interactivityData) {
101
98
  const container = this.container, repulseOptions = container.actualOptions.interactivity?.modes.repulse;
102
99
  if (!repulseOptions) {
103
100
  return;
@@ -138,15 +135,15 @@ export class Repulser extends ExternalInteractorBase {
138
135
  }
139
136
  repulse.particles = [];
140
137
  }
141
- };
142
- #hoverRepulse = interactivityData => {
138
+ }
139
+ #hoverRepulse(interactivityData) {
143
140
  const container = this.container, mousePos = interactivityData.mouse.position, repulseRadius = container.retina.repulseModeDistance;
144
141
  if (!repulseRadius || repulseRadius < minRadius || !mousePos) {
145
142
  return;
146
143
  }
147
144
  this.#processRepulse(interactivityData, mousePos, repulseRadius, new Circle(mousePos.x, mousePos.y, repulseRadius));
148
- };
149
- #processRepulse = (interactivityData, position, repulseRadius, area, divRepulse) => {
145
+ }
146
+ #processRepulse(interactivityData, position, repulseRadius, area, divRepulse) {
150
147
  const container = this.container, query = container.particles.grid.query(area, p => this.isEnabled(interactivityData, p)), repulseOptions = container.actualOptions.interactivity?.modes.repulse;
151
148
  if (!repulseOptions) {
152
149
  return;
@@ -159,7 +156,7 @@ export class Repulser extends ExternalInteractorBase {
159
156
  this.#trackInteractedParticle(particle);
160
157
  particle.position.addTo(this.#normVec);
161
158
  }
162
- };
159
+ }
163
160
  #restoreParticles() {
164
161
  const restore = this.container.actualOptions.interactivity?.modes.repulse?.restore;
165
162
  if (!restore?.enable || !this.#restoreData.size) {
@@ -196,7 +193,7 @@ export class Repulser extends ExternalInteractorBase {
196
193
  }
197
194
  }
198
195
  }
199
- #singleSelectorRepulse = (interactivityData, selector, div) => {
196
+ #singleSelectorRepulse(interactivityData, selector, div) {
200
197
  const container = this.container, repulse = container.actualOptions.interactivity?.modes.repulse;
201
198
  if (!repulse) {
202
199
  return;
@@ -214,7 +211,7 @@ export class Repulser extends ExternalInteractorBase {
214
211
  : new Rectangle(elem.offsetLeft * pxRatio, elem.offsetTop * pxRatio, elem.offsetWidth * pxRatio, elem.offsetHeight * pxRatio), divs = repulse.divs, divRepulse = divMode(divs, elem);
215
212
  this.#processRepulse(interactivityData, pos, repulseRadius, area, divRepulse);
216
213
  });
217
- };
214
+ }
218
215
  #trackInteractedParticle(particle) {
219
216
  this.#interactedThisFrame.add(particle);
220
217
  const restore = this.container.actualOptions.interactivity?.modes.repulse?.restore;
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 loadExternalRepulseInteraction(engine) {
4
- engine.checkVersion("4.1.3");
4
+ engine.checkVersion("4.2.0");
5
5
  await engine.pluginManager.register((e) => {
6
6
  ensureInteractivityPluginLoaded(e);
7
7
  const pluginManager = e.pluginManager;
package/cjs/index.lazy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export async function loadExternalRepulseInteraction(engine) {
2
- engine.checkVersion("4.1.3");
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,19 +1,13 @@
1
- import { EasingType, isNull } from "@tsparticles/engine";
1
+ import { isNull, loadProperty } from "@tsparticles/engine";
2
2
  export class RepulseBase {
3
- distance;
4
- duration;
5
- easing;
6
- factor;
7
- maxSpeed;
3
+ distance = 200;
4
+ duration = 0.4;
5
+ easing = "ease-out-quad";
6
+ factor = 100;
7
+ maxSpeed = 50;
8
8
  restore;
9
- speed;
9
+ speed = 1;
10
10
  constructor() {
11
- this.distance = 200;
12
- this.duration = 0.4;
13
- this.factor = 100;
14
- this.speed = 1;
15
- this.maxSpeed = 50;
16
- this.easing = EasingType.easeOutQuad;
17
11
  this.restore = {
18
12
  enable: false,
19
13
  delay: 0,
@@ -25,24 +19,12 @@ export class RepulseBase {
25
19
  if (isNull(data)) {
26
20
  return;
27
21
  }
28
- if (data.distance !== undefined) {
29
- this.distance = data.distance;
30
- }
31
- if (data.duration !== undefined) {
32
- this.duration = data.duration;
33
- }
34
- if (data.easing !== undefined) {
35
- this.easing = data.easing;
36
- }
37
- if (data.factor !== undefined) {
38
- this.factor = data.factor;
39
- }
40
- if (data.speed !== undefined) {
41
- this.speed = data.speed;
42
- }
43
- if (data.maxSpeed !== undefined) {
44
- this.maxSpeed = data.maxSpeed;
45
- }
22
+ loadProperty(this, "distance", data.distance);
23
+ loadProperty(this, "duration", data.duration);
24
+ loadProperty(this, "easing", data.easing);
25
+ loadProperty(this, "factor", data.factor);
26
+ loadProperty(this, "speed", data.speed);
27
+ loadProperty(this, "maxSpeed", data.maxSpeed);
46
28
  if (data.restore !== undefined) {
47
29
  this.restore.enable = data.restore.enable ?? this.restore.enable;
48
30
  this.restore.delay = data.restore.delay ?? this.restore.delay;
@@ -1,18 +1,12 @@
1
- import { isNull } from "@tsparticles/engine";
1
+ import { isNull, loadProperty, } from "@tsparticles/engine";
2
2
  import { RepulseBase } from "./RepulseBase.js";
3
3
  export class RepulseDiv extends RepulseBase {
4
- selectors;
5
- constructor() {
6
- super();
7
- this.selectors = [];
8
- }
4
+ selectors = [];
9
5
  load(data) {
10
6
  super.load(data);
11
7
  if (isNull(data)) {
12
8
  return;
13
9
  }
14
- if (data.selectors !== undefined) {
15
- this.selectors = data.selectors;
16
- }
10
+ loadProperty(this, "selectors", data.selectors);
17
11
  }
18
12
  }
package/esm/Repulser.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Circle, Rectangle, Vector, clamp, getDistances, half, isInArray, millisecondsToSeconds, safeDocument, } from "@tsparticles/engine";
1
+ import { Circle, Rectangle, Vector, clamp, getDistances, half, isInArray, loadOptionProperty, millisecondsToSeconds, safeDocument, } from "@tsparticles/engine";
2
2
  import { DivType, ExternalInteractorBase, divMode, divModeExecute, isDivModeEnabled, mouseMoveEvent, } from "@tsparticles/plugin-interactivity";
3
3
  import { Repulse } from "./Options/Classes/Repulse.js";
4
4
  const repulseMode = "repulse", minDistance = 0, repulseRadiusFactor = 6, repulseRadiusPower = 3, squarePower = 2, minRadius = 0, minSpeed = 0, easingOffset = 1, minRestoreSpeed = 0.001, maxRestoreSpeed = 1, restoreEpsilon = 0.5;
@@ -90,14 +90,11 @@ export class Repulser extends ExternalInteractorBase {
90
90
  return isInArray(repulseMode, hoverMode) || isInArray(repulseMode, clickMode) || divRepulse;
91
91
  }
92
92
  loadModeOptions(options, ...sources) {
93
- options.repulse ??= new Repulse();
94
- for (const source of sources) {
95
- options.repulse.load(source?.repulse);
96
- }
93
+ loadOptionProperty(options, "repulse", Repulse, ...sources);
97
94
  }
98
95
  reset() {
99
96
  }
100
- #clickRepulse = interactivityData => {
97
+ #clickRepulse(interactivityData) {
101
98
  const container = this.container, repulseOptions = container.actualOptions.interactivity?.modes.repulse;
102
99
  if (!repulseOptions) {
103
100
  return;
@@ -138,15 +135,15 @@ export class Repulser extends ExternalInteractorBase {
138
135
  }
139
136
  repulse.particles = [];
140
137
  }
141
- };
142
- #hoverRepulse = interactivityData => {
138
+ }
139
+ #hoverRepulse(interactivityData) {
143
140
  const container = this.container, mousePos = interactivityData.mouse.position, repulseRadius = container.retina.repulseModeDistance;
144
141
  if (!repulseRadius || repulseRadius < minRadius || !mousePos) {
145
142
  return;
146
143
  }
147
144
  this.#processRepulse(interactivityData, mousePos, repulseRadius, new Circle(mousePos.x, mousePos.y, repulseRadius));
148
- };
149
- #processRepulse = (interactivityData, position, repulseRadius, area, divRepulse) => {
145
+ }
146
+ #processRepulse(interactivityData, position, repulseRadius, area, divRepulse) {
150
147
  const container = this.container, query = container.particles.grid.query(area, p => this.isEnabled(interactivityData, p)), repulseOptions = container.actualOptions.interactivity?.modes.repulse;
151
148
  if (!repulseOptions) {
152
149
  return;
@@ -159,7 +156,7 @@ export class Repulser extends ExternalInteractorBase {
159
156
  this.#trackInteractedParticle(particle);
160
157
  particle.position.addTo(this.#normVec);
161
158
  }
162
- };
159
+ }
163
160
  #restoreParticles() {
164
161
  const restore = this.container.actualOptions.interactivity?.modes.repulse?.restore;
165
162
  if (!restore?.enable || !this.#restoreData.size) {
@@ -196,7 +193,7 @@ export class Repulser extends ExternalInteractorBase {
196
193
  }
197
194
  }
198
195
  }
199
- #singleSelectorRepulse = (interactivityData, selector, div) => {
196
+ #singleSelectorRepulse(interactivityData, selector, div) {
200
197
  const container = this.container, repulse = container.actualOptions.interactivity?.modes.repulse;
201
198
  if (!repulse) {
202
199
  return;
@@ -214,7 +211,7 @@ export class Repulser extends ExternalInteractorBase {
214
211
  : new Rectangle(elem.offsetLeft * pxRatio, elem.offsetTop * pxRatio, elem.offsetWidth * pxRatio, elem.offsetHeight * pxRatio), divs = repulse.divs, divRepulse = divMode(divs, elem);
215
212
  this.#processRepulse(interactivityData, pos, repulseRadius, area, divRepulse);
216
213
  });
217
- };
214
+ }
218
215
  #trackInteractedParticle(particle) {
219
216
  this.#interactedThisFrame.add(particle);
220
217
  const restore = this.container.actualOptions.interactivity?.modes.repulse?.restore;
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 loadExternalRepulseInteraction(engine) {
4
- engine.checkVersion("4.1.3");
4
+ engine.checkVersion("4.2.0");
5
5
  await engine.pluginManager.register((e) => {
6
6
  ensureInteractivityPluginLoaded(e);
7
7
  const pluginManager = e.pluginManager;
package/esm/index.lazy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export async function loadExternalRepulseInteraction(engine) {
2
- engine.checkVersion("4.1.3");
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-external-repulse",
3
- "version": "4.1.3",
3
+ "version": "4.2.0",
4
4
  "description": "tsParticles repulse 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.1.3",
101
- "@tsparticles/plugin-interactivity": "4.1.3"
100
+ "@tsparticles/engine": "4.2.0",
101
+ "@tsparticles/plugin-interactivity": "4.2.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.repulse.js","children":[{"name":"dist/browser","children":[{"name":"Options/Classes","children":[{"uid":"3de31995-1","name":"RepulseBase.js"},{"uid":"3de31995-3","name":"RepulseDiv.js"},{"uid":"3de31995-5","name":"Repulse.js"}]},{"uid":"3de31995-7","name":"Repulser.js"},{"uid":"3de31995-9","name":"index.js"},{"uid":"3de31995-11","name":"browser.js"}]}]}],"isRoot":true},"nodeParts":{"3de31995-1":{"renderedLength":1672,"gzipLength":0,"brotliLength":0,"metaUid":"3de31995-0"},"3de31995-3":{"renderedLength":404,"gzipLength":0,"brotliLength":0,"metaUid":"3de31995-2"},"3de31995-5":{"renderedLength":395,"gzipLength":0,"brotliLength":0,"metaUid":"3de31995-4"},"3de31995-7":{"renderedLength":12428,"gzipLength":0,"brotliLength":0,"metaUid":"3de31995-6"},"3de31995-9":{"renderedLength":459,"gzipLength":0,"brotliLength":0,"metaUid":"3de31995-8"},"3de31995-11":{"renderedLength":203,"gzipLength":0,"brotliLength":0,"metaUid":"3de31995-10"}},"nodeMetas":{"3de31995-0":{"id":"/dist/browser/Options/Classes/RepulseBase.js","moduleParts":{"tsparticles.interaction.external.repulse.js":"3de31995-1"},"imported":[{"uid":"3de31995-13"}],"importedBy":[{"uid":"3de31995-8"},{"uid":"3de31995-2"},{"uid":"3de31995-4"}]},"3de31995-2":{"id":"/dist/browser/Options/Classes/RepulseDiv.js","moduleParts":{"tsparticles.interaction.external.repulse.js":"3de31995-3"},"imported":[{"uid":"3de31995-13"},{"uid":"3de31995-0"}],"importedBy":[{"uid":"3de31995-8"},{"uid":"3de31995-4"}]},"3de31995-4":{"id":"/dist/browser/Options/Classes/Repulse.js","moduleParts":{"tsparticles.interaction.external.repulse.js":"3de31995-5"},"imported":[{"uid":"3de31995-13"},{"uid":"3de31995-0"},{"uid":"3de31995-2"}],"importedBy":[{"uid":"3de31995-8"},{"uid":"3de31995-6"}]},"3de31995-6":{"id":"/dist/browser/Repulser.js","moduleParts":{"tsparticles.interaction.external.repulse.js":"3de31995-7"},"imported":[{"uid":"3de31995-13"},{"uid":"3de31995-12"},{"uid":"3de31995-4"}],"importedBy":[{"uid":"3de31995-8"}]},"3de31995-8":{"id":"/dist/browser/index.js","moduleParts":{"tsparticles.interaction.external.repulse.js":"3de31995-9"},"imported":[{"uid":"3de31995-12"},{"uid":"3de31995-6"},{"uid":"3de31995-0"},{"uid":"3de31995-2"},{"uid":"3de31995-4"}],"importedBy":[{"uid":"3de31995-10"}]},"3de31995-10":{"id":"/dist/browser/browser.js","moduleParts":{"tsparticles.interaction.external.repulse.js":"3de31995-11"},"imported":[{"uid":"3de31995-8"}],"importedBy":[],"isEntry":true},"3de31995-12":{"id":"@tsparticles/plugin-interactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"3de31995-8"},{"uid":"3de31995-6"}],"isExternal":true},"3de31995-13":{"id":"@tsparticles/engine","moduleParts":{},"imported":[],"importedBy":[{"uid":"3de31995-6"},{"uid":"3de31995-0"},{"uid":"3de31995-2"},{"uid":"3de31995-4"}],"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.external.repulse.js","children":[{"name":"dist/browser","children":[{"name":"Options/Classes","children":[{"uid":"d6b1e29d-1","name":"RepulseBase.js"},{"uid":"d6b1e29d-3","name":"RepulseDiv.js"},{"uid":"d6b1e29d-5","name":"Repulse.js"}]},{"uid":"d6b1e29d-7","name":"Repulser.js"},{"uid":"d6b1e29d-9","name":"index.js"},{"uid":"d6b1e29d-11","name":"browser.js"}]}]}],"isRoot":true},"nodeParts":{"d6b1e29d-1":{"renderedLength":1258,"gzipLength":0,"brotliLength":0,"metaUid":"d6b1e29d-0"},"d6b1e29d-3":{"renderedLength":278,"gzipLength":0,"brotliLength":0,"metaUid":"d6b1e29d-2"},"d6b1e29d-5":{"renderedLength":395,"gzipLength":0,"brotliLength":0,"metaUid":"d6b1e29d-4"},"d6b1e29d-7":{"renderedLength":12324,"gzipLength":0,"brotliLength":0,"metaUid":"d6b1e29d-6"},"d6b1e29d-9":{"renderedLength":459,"gzipLength":0,"brotliLength":0,"metaUid":"d6b1e29d-8"},"d6b1e29d-11":{"renderedLength":203,"gzipLength":0,"brotliLength":0,"metaUid":"d6b1e29d-10"}},"nodeMetas":{"d6b1e29d-0":{"id":"/dist/browser/Options/Classes/RepulseBase.js","moduleParts":{"tsparticles.interaction.external.repulse.js":"d6b1e29d-1"},"imported":[{"uid":"d6b1e29d-13"}],"importedBy":[{"uid":"d6b1e29d-8"},{"uid":"d6b1e29d-2"},{"uid":"d6b1e29d-4"}]},"d6b1e29d-2":{"id":"/dist/browser/Options/Classes/RepulseDiv.js","moduleParts":{"tsparticles.interaction.external.repulse.js":"d6b1e29d-3"},"imported":[{"uid":"d6b1e29d-13"},{"uid":"d6b1e29d-0"}],"importedBy":[{"uid":"d6b1e29d-8"},{"uid":"d6b1e29d-4"}]},"d6b1e29d-4":{"id":"/dist/browser/Options/Classes/Repulse.js","moduleParts":{"tsparticles.interaction.external.repulse.js":"d6b1e29d-5"},"imported":[{"uid":"d6b1e29d-13"},{"uid":"d6b1e29d-0"},{"uid":"d6b1e29d-2"}],"importedBy":[{"uid":"d6b1e29d-8"},{"uid":"d6b1e29d-6"}]},"d6b1e29d-6":{"id":"/dist/browser/Repulser.js","moduleParts":{"tsparticles.interaction.external.repulse.js":"d6b1e29d-7"},"imported":[{"uid":"d6b1e29d-13"},{"uid":"d6b1e29d-12"},{"uid":"d6b1e29d-4"}],"importedBy":[{"uid":"d6b1e29d-8"}]},"d6b1e29d-8":{"id":"/dist/browser/index.js","moduleParts":{"tsparticles.interaction.external.repulse.js":"d6b1e29d-9"},"imported":[{"uid":"d6b1e29d-12"},{"uid":"d6b1e29d-6"},{"uid":"d6b1e29d-0"},{"uid":"d6b1e29d-2"},{"uid":"d6b1e29d-4"}],"importedBy":[{"uid":"d6b1e29d-10"}]},"d6b1e29d-10":{"id":"/dist/browser/browser.js","moduleParts":{"tsparticles.interaction.external.repulse.js":"d6b1e29d-11"},"imported":[{"uid":"d6b1e29d-8"}],"importedBy":[],"isEntry":true},"d6b1e29d-12":{"id":"@tsparticles/plugin-interactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"d6b1e29d-8"},{"uid":"d6b1e29d-6"}],"isExternal":true},"d6b1e29d-13":{"id":"@tsparticles/engine","moduleParts":{},"imported":[],"importedBy":[{"uid":"d6b1e29d-6"},{"uid":"d6b1e29d-0"},{"uid":"d6b1e29d-2"},{"uid":"d6b1e29d-4"}],"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
- /* External Interaction v4.1.3 */
2
+ /* External 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,20 +7,14 @@
7
7
  })(this, (function (exports, pluginInteractivity, engine) { 'use strict';
8
8
 
9
9
  class RepulseBase {
10
- distance;
11
- duration;
12
- easing;
13
- factor;
14
- maxSpeed;
10
+ distance = 200;
11
+ duration = 0.4;
12
+ easing = "ease-out-quad";
13
+ factor = 100;
14
+ maxSpeed = 50;
15
15
  restore;
16
- speed;
16
+ speed = 1;
17
17
  constructor() {
18
- this.distance = 200;
19
- this.duration = 0.4;
20
- this.factor = 100;
21
- this.speed = 1;
22
- this.maxSpeed = 50;
23
- this.easing = engine.EasingType.easeOutQuad;
24
18
  this.restore = {
25
19
  enable: false,
26
20
  delay: 0,
@@ -32,24 +26,12 @@
32
26
  if (engine.isNull(data)) {
33
27
  return;
34
28
  }
35
- if (data.distance !== undefined) {
36
- this.distance = data.distance;
37
- }
38
- if (data.duration !== undefined) {
39
- this.duration = data.duration;
40
- }
41
- if (data.easing !== undefined) {
42
- this.easing = data.easing;
43
- }
44
- if (data.factor !== undefined) {
45
- this.factor = data.factor;
46
- }
47
- if (data.speed !== undefined) {
48
- this.speed = data.speed;
49
- }
50
- if (data.maxSpeed !== undefined) {
51
- this.maxSpeed = data.maxSpeed;
52
- }
29
+ engine.loadProperty(this, "distance", data.distance);
30
+ engine.loadProperty(this, "duration", data.duration);
31
+ engine.loadProperty(this, "easing", data.easing);
32
+ engine.loadProperty(this, "factor", data.factor);
33
+ engine.loadProperty(this, "speed", data.speed);
34
+ engine.loadProperty(this, "maxSpeed", data.maxSpeed);
53
35
  if (data.restore !== undefined) {
54
36
  this.restore.enable = data.restore.enable ?? this.restore.enable;
55
37
  this.restore.delay = data.restore.delay ?? this.restore.delay;
@@ -60,19 +42,13 @@
60
42
  }
61
43
 
62
44
  class RepulseDiv extends RepulseBase {
63
- selectors;
64
- constructor() {
65
- super();
66
- this.selectors = [];
67
- }
45
+ selectors = [];
68
46
  load(data) {
69
47
  super.load(data);
70
48
  if (engine.isNull(data)) {
71
49
  return;
72
50
  }
73
- if (data.selectors !== undefined) {
74
- this.selectors = data.selectors;
75
- }
51
+ engine.loadProperty(this, "selectors", data.selectors);
76
52
  }
77
53
  }
78
54
 
@@ -180,14 +156,11 @@
180
156
  return engine.isInArray(repulseMode, hoverMode) || engine.isInArray(repulseMode, clickMode) || divRepulse;
181
157
  }
182
158
  loadModeOptions(options, ...sources) {
183
- options.repulse ??= new Repulse();
184
- for (const source of sources) {
185
- options.repulse.load(source?.repulse);
186
- }
159
+ engine.loadOptionProperty(options, "repulse", Repulse, ...sources);
187
160
  }
188
161
  reset() {
189
162
  }
190
- #clickRepulse = interactivityData => {
163
+ #clickRepulse(interactivityData) {
191
164
  const container = this.container, repulseOptions = container.actualOptions.interactivity?.modes.repulse;
192
165
  if (!repulseOptions) {
193
166
  return;
@@ -228,15 +201,15 @@
228
201
  }
229
202
  repulse.particles = [];
230
203
  }
231
- };
232
- #hoverRepulse = interactivityData => {
204
+ }
205
+ #hoverRepulse(interactivityData) {
233
206
  const container = this.container, mousePos = interactivityData.mouse.position, repulseRadius = container.retina.repulseModeDistance;
234
207
  if (!repulseRadius || repulseRadius < minRadius || !mousePos) {
235
208
  return;
236
209
  }
237
210
  this.#processRepulse(interactivityData, mousePos, repulseRadius, new engine.Circle(mousePos.x, mousePos.y, repulseRadius));
238
- };
239
- #processRepulse = (interactivityData, position, repulseRadius, area, divRepulse) => {
211
+ }
212
+ #processRepulse(interactivityData, position, repulseRadius, area, divRepulse) {
240
213
  const container = this.container, query = container.particles.grid.query(area, p => this.isEnabled(interactivityData, p)), repulseOptions = container.actualOptions.interactivity?.modes.repulse;
241
214
  if (!repulseOptions) {
242
215
  return;
@@ -249,7 +222,7 @@
249
222
  this.#trackInteractedParticle(particle);
250
223
  particle.position.addTo(this.#normVec);
251
224
  }
252
- };
225
+ }
253
226
  #restoreParticles() {
254
227
  const restore = this.container.actualOptions.interactivity?.modes.repulse?.restore;
255
228
  if (!restore?.enable || !this.#restoreData.size) {
@@ -286,7 +259,7 @@
286
259
  }
287
260
  }
288
261
  }
289
- #singleSelectorRepulse = (interactivityData, selector, div) => {
262
+ #singleSelectorRepulse(interactivityData, selector, div) {
290
263
  const container = this.container, repulse = container.actualOptions.interactivity?.modes.repulse;
291
264
  if (!repulse) {
292
265
  return;
@@ -304,7 +277,7 @@
304
277
  : new engine.Rectangle(elem.offsetLeft * pxRatio, elem.offsetTop * pxRatio, elem.offsetWidth * pxRatio, elem.offsetHeight * pxRatio), divs = repulse.divs, divRepulse = pluginInteractivity.divMode(divs, elem);
305
278
  this.#processRepulse(interactivityData, pos, repulseRadius, area, divRepulse);
306
279
  });
307
- };
280
+ }
308
281
  #trackInteractedParticle(particle) {
309
282
  this.#interactedThisFrame.add(particle);
310
283
  const restore = this.container.actualOptions.interactivity?.modes.repulse?.restore;
@@ -330,7 +303,7 @@
330
303
  }
331
304
 
332
305
  async function loadExternalRepulseInteraction(engine) {
333
- engine.checkVersion("4.1.3");
306
+ engine.checkVersion("4.2.0");
334
307
  await engine.pluginManager.register((e) => {
335
308
  pluginInteractivity.ensureInteractivityPluginLoaded(e);
336
309
  const pluginManager = e.pluginManager;
@@ -1 +1 @@
1
- !function(e){e.__tsParticlesInternals=e.__tsParticlesInternals||{},e.__tsParticlesInternals.bundles=e.__tsParticlesInternals.bundles||{},e.__tsParticlesInternals.effects=e.__tsParticlesInternals.effects||{},e.__tsParticlesInternals.engine=e.__tsParticlesInternals.engine||{},e.__tsParticlesInternals.interactions=e.__tsParticlesInternals.interactions||{},e.__tsParticlesInternals.palettes=e.__tsParticlesInternals.palettes||{},e.__tsParticlesInternals.paths=e.__tsParticlesInternals.paths||{},e.__tsParticlesInternals.plugins=e.__tsParticlesInternals.plugins||{},e.__tsParticlesInternals.plugins=e.__tsParticlesInternals.plugins||{},e.__tsParticlesInternals.plugins.emittersShapes=e.__tsParticlesInternals.plugins.emittersShapes||{},e.__tsParticlesInternals.presets=e.__tsParticlesInternals.presets||{},e.__tsParticlesInternals.shapes=e.__tsParticlesInternals.shapes||{},e.__tsParticlesInternals.updaters=e.__tsParticlesInternals.updaters||{},e.__tsParticlesInternals.utils=e.__tsParticlesInternals.utils||{},e.__tsParticlesInternals.canvas=e.__tsParticlesInternals.canvas||{},e.__tsParticlesInternals.canvas=e.__tsParticlesInternals.canvas||{},e.__tsParticlesInternals.canvas.utils=e.__tsParticlesInternals.canvas.utils||{},e.__tsParticlesInternals.path=e.__tsParticlesInternals.path||{},e.__tsParticlesInternals.path=e.__tsParticlesInternals.path||{},e.__tsParticlesInternals.path.utils=e.__tsParticlesInternals.path.utils||{};var t="undefined"!=typeof Proxy?function(e){return new Proxy(e,{get:function(e,t){return t in e||(e[t]={}),e[t]}})}:function(e){return e};e.__tsParticlesInternals.bundles=t(e.__tsParticlesInternals.bundles),e.__tsParticlesInternals.effects=t(e.__tsParticlesInternals.effects),e.__tsParticlesInternals.interactions=t(e.__tsParticlesInternals.interactions),e.__tsParticlesInternals.palettes=t(e.__tsParticlesInternals.palettes),e.__tsParticlesInternals.paths=t(e.__tsParticlesInternals.paths),e.__tsParticlesInternals.plugins=t(e.__tsParticlesInternals.plugins),e.__tsParticlesInternals.plugins.emittersShapes=t(e.__tsParticlesInternals.plugins.emittersShapes),e.__tsParticlesInternals.presets=t(e.__tsParticlesInternals.presets),e.__tsParticlesInternals.shapes=t(e.__tsParticlesInternals.shapes),e.__tsParticlesInternals.updaters=t(e.__tsParticlesInternals.updaters),e.__tsParticlesInternals.utils=t(e.__tsParticlesInternals.utils),e.__tsParticlesInternals.canvas=t(e.__tsParticlesInternals.canvas),e.__tsParticlesInternals.path=t(e.__tsParticlesInternals.path),e.tsparticlesInternalExports=e.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/plugin-interactivity","@tsparticles/engine"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).__tsParticlesInternals=e.__tsParticlesInternals||{},e.__tsParticlesInternals.interactions=e.__tsParticlesInternals.interactions||{},e.__tsParticlesInternals.interactions.externalRepulse=e.__tsParticlesInternals.interactions.externalRepulse||{}),e.__tsParticlesInternals.plugins.interactivity,e.__tsParticlesInternals.engine)}(this,function(e,t,s){"use strict";class i{distance;duration;easing;factor;maxSpeed;restore;speed;constructor(){this.distance=200,this.duration=.4,this.factor=100,this.speed=1,this.maxSpeed=50,this.easing=s.EasingType.easeOutQuad,this.restore={enable:!1,delay:0,speed:.08,follow:!0}}load(e){s.isNull(e)||(void 0!==e.distance&&(this.distance=e.distance),void 0!==e.duration&&(this.duration=e.duration),void 0!==e.easing&&(this.easing=e.easing),void 0!==e.factor&&(this.factor=e.factor),void 0!==e.speed&&(this.speed=e.speed),void 0!==e.maxSpeed&&(this.maxSpeed=e.maxSpeed),void 0!==e.restore&&(this.restore.enable=e.restore.enable??this.restore.enable,this.restore.delay=e.restore.delay??this.restore.delay,this.restore.speed=e.restore.speed??this.restore.speed,this.restore.follow=e.restore.follow??this.restore.follow))}}class n extends i{selectors;constructor(){super(),this.selectors=[]}load(e){super.load(e),s.isNull(e)||void 0!==e.selectors&&(this.selectors=e.selectors)}}class a extends i{divs;load(e){super.load(e),s.isNull(e)||(this.divs=s.executeOnSingleOrMultiple(e.divs,e=>{const t=new n;return t.load(e),t}))}}const r="repulse";class l extends t.ExternalInteractorBase{handleClickMode;#e;#t;#s;#i;#n;#a;constructor(e,t){super(t),this.#n=e,this.#s=0,this.#i=s.Vector.origin,this.#t=new Set,this.#e=s.Vector.origin,this.#a=new Map,t.repulse??={particles:[]},this.handleClickMode=(e,i)=>{const n=this.container.actualOptions,a=n.interactivity?.modes.repulse;if(!a||e!==r)return;t.repulse??={particles:[]};const l=t.repulse;l.clicking=!0,l.count=0;for(const e of t.repulse.particles)this.isEnabled(i,e)&&e.velocity.setTo(e.initialVelocity);l.particles=[],l.finish=!1,setTimeout(()=>{t.destroyed||(l.clicking=!1)},a.duration*s.millisecondsToSeconds)}}get maxDistance(){return this.#s}clear(){}init(){const e=this.container,t=e.actualOptions.interactivity?.modes.repulse;t&&(this.#s=t.distance,e.retina.repulseModeDistance=t.distance*e.retina.pixelRatio)}interact(e){this.#t.clear();const i=this.container.actualOptions,n=e.status===t.mouseMoveEvent,a=i.interactivity?.events;if(!a)return;const l=a.onHover,c=l.enable,o=l.mode,p=a.onClick,d=p.enable,u=p.mode,_=a.onDiv;n&&c&&s.isInArray(r,o)?this.#r(e):d&&s.isInArray(r,u)?this.#l(e):t.divModeExecute(r,_,(t,s)=>{this.#c(e,t,s)}),this.#o()}isEnabled(e,i){const n=this.container.actualOptions,a=e.mouse,l=(i?.interactivity??n.interactivity)?.events;if(!l)return!1;const c=l.onDiv,o=l.onHover,p=l.onClick,d=t.isDivModeEnabled(r,c);if(!(d||o.enable&&a.position||p.enable&&a.clickPosition))return!1;const u=o.mode,_=p.mode;return s.isInArray(r,u)||s.isInArray(r,_)||d}loadModeOptions(e,...t){e.repulse??=new a;for(const s of t)e.repulse.load(s?.repulse)}reset(){}#l=e=>{const t=this.container,i=t.actualOptions.interactivity?.modes.repulse;if(!i)return;const n=t.repulse??{particles:[]};if(n.finish||(n.count??=0,n.count++,n.count===t.particles.count&&(n.finish=!0)),n.clicking){const a=t.retina.repulseModeDistance;if(!a||a<0)return;const r=Math.pow(a/6,3),l=e.mouse.clickPosition;if(void 0===l)return;const c=new s.Circle(l.x,l.y,r),o=t.particles.grid.query(c,t=>this.isEnabled(e,t));for(const e of o){const{dx:t,dy:a,distance:c}=s.getDistances(l,e.position),o=c**2,p=-r*i.speed/o;o<=r&&(this.#p(e),n.particles.push(e),this.#e.x=t,this.#e.y=a,this.#e.length=p,e.velocity.setTo(this.#e))}}else if(!1===n.clicking){for(const e of n.particles)e.velocity.setTo(e.initialVelocity);n.particles=[]}};#r=e=>{const t=this.container,i=e.mouse.position,n=t.retina.repulseModeDistance;!n||n<0||!i||this.#d(e,i,n,new s.Circle(i.x,i.y,n))};#d=(e,t,i,n,a)=>{const r=this.container,l=r.particles.grid.query(n,t=>this.isEnabled(e,t)),c=r.actualOptions.interactivity?.modes.repulse;if(!c)return;const{easing:o,speed:p,factor:d,maxSpeed:u}=c,_=this.#n.getEasing(o),h=(a?.speed??p)*d;for(const e of l){const{dx:n,dy:a,distance:r}=s.getDistances(e.position,t),l=s.clamp(_(1-r/i)*h,0,u);this.#i.x=r?n/r*l:h,this.#i.y=r?a/r*l:h,this.#p(e),e.position.addTo(this.#i)}};#o(){const e=this.container.actualOptions.interactivity?.modes.repulse?.restore;if(!e?.enable||!this.#a.size)return;const t=Date.now(),i=e.delay*s.millisecondsToSeconds,n=Math.max(.001,Math.min(1,e.speed));for(const[s,a]of this.#a){if(this.#t.has(s))continue;if(s.destroyed){this.#a.delete(s);continue}const r=a.target;if(t-a.lastInteractionTime<i)continue;e.follow&&s.options.move.enable&&(r.x+=s.velocity.x,r.y+=s.velocity.y,r.z+=s.velocity.z);const l=r.x-s.position.x,c=r.y-s.position.y,o=r.z-s.position.z;s.position.x+=l*n,s.position.y+=c*n,s.position.z+=o*n,Math.abs(l)<=.5&&Math.abs(c)<=.5&&(s.position.x=r.x,s.position.y=r.y,s.position.z=r.z,this.#a.delete(s))}}#c=(e,i,n)=>{const a=this.container,r=a.actualOptions.interactivity?.modes.repulse;if(!r)return;const l=s.safeDocument().querySelectorAll(i);l.length&&l.forEach(i=>{const l=i,c=a.retina.pixelRatio,o={x:(l.offsetLeft+l.offsetWidth*s.half)*c,y:(l.offsetTop+l.offsetHeight*s.half)*c},p=l.offsetWidth*s.half*c,d=n.type===t.DivType.circle?new s.Circle(o.x,o.y,p):new s.Rectangle(l.offsetLeft*c,l.offsetTop*c,l.offsetWidth*c,l.offsetHeight*c),u=r.divs,_=t.divMode(u,l);this.#d(e,o,p,d,_)})};#p(e){this.#t.add(e);const t=this.container.actualOptions.interactivity?.modes.repulse?.restore;if(!t?.enable)return;const s=Date.now();let i=this.#a.get(e);i||(i={target:e.position.copy(),lastInteractionTime:s},this.#a.set(e,i)),i.lastInteractionTime=s,t.follow&&e.options.move.enable&&(i.target.x+=e.velocity.x,i.target.y+=e.velocity.y,i.target.z+=e.velocity.z)}}async function c(e){e.checkVersion("4.1.3"),await e.pluginManager.register(e=>{t.ensureInteractivityPluginLoaded(e);const s=e.pluginManager;s.addInteractor?.("externalRepulse",e=>Promise.resolve(new l(s,e)))})}const o=globalThis;o.__tsParticlesInternals=o.__tsParticlesInternals??{},o.loadExternalRepulseInteraction=c,e.Repulse=a,e.RepulseBase=i,e.RepulseDiv=n,e.loadExternalRepulseInteraction=c}),Object.assign(globalThis.window||globalThis,{loadExternalRepulseInteraction:(globalThis.__tsParticlesInternals.interactions.externalRepulse||{}).loadExternalRepulseInteraction}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
1
+ !function(e){e.__tsParticlesInternals=e.__tsParticlesInternals||{},e.__tsParticlesInternals.bundles=e.__tsParticlesInternals.bundles||{},e.__tsParticlesInternals.effects=e.__tsParticlesInternals.effects||{},e.__tsParticlesInternals.engine=e.__tsParticlesInternals.engine||{},e.__tsParticlesInternals.interactions=e.__tsParticlesInternals.interactions||{},e.__tsParticlesInternals.palettes=e.__tsParticlesInternals.palettes||{},e.__tsParticlesInternals.paths=e.__tsParticlesInternals.paths||{},e.__tsParticlesInternals.plugins=e.__tsParticlesInternals.plugins||{},e.__tsParticlesInternals.plugins=e.__tsParticlesInternals.plugins||{},e.__tsParticlesInternals.plugins.emittersShapes=e.__tsParticlesInternals.plugins.emittersShapes||{},e.__tsParticlesInternals.presets=e.__tsParticlesInternals.presets||{},e.__tsParticlesInternals.shapes=e.__tsParticlesInternals.shapes||{},e.__tsParticlesInternals.updaters=e.__tsParticlesInternals.updaters||{},e.__tsParticlesInternals.utils=e.__tsParticlesInternals.utils||{},e.__tsParticlesInternals.canvas=e.__tsParticlesInternals.canvas||{},e.__tsParticlesInternals.canvas=e.__tsParticlesInternals.canvas||{},e.__tsParticlesInternals.canvas.utils=e.__tsParticlesInternals.canvas.utils||{},e.__tsParticlesInternals.path=e.__tsParticlesInternals.path||{},e.__tsParticlesInternals.path=e.__tsParticlesInternals.path||{},e.__tsParticlesInternals.path.utils=e.__tsParticlesInternals.path.utils||{};var t="undefined"!=typeof Proxy?function(e){return new Proxy(e,{get:function(e,t){return t in e||(e[t]={}),e[t]}})}:function(e){return e};e.__tsParticlesInternals.bundles=t(e.__tsParticlesInternals.bundles),e.__tsParticlesInternals.effects=t(e.__tsParticlesInternals.effects),e.__tsParticlesInternals.interactions=t(e.__tsParticlesInternals.interactions),e.__tsParticlesInternals.palettes=t(e.__tsParticlesInternals.palettes),e.__tsParticlesInternals.paths=t(e.__tsParticlesInternals.paths),e.__tsParticlesInternals.plugins=t(e.__tsParticlesInternals.plugins),e.__tsParticlesInternals.plugins.emittersShapes=t(e.__tsParticlesInternals.plugins.emittersShapes),e.__tsParticlesInternals.presets=t(e.__tsParticlesInternals.presets),e.__tsParticlesInternals.shapes=t(e.__tsParticlesInternals.shapes),e.__tsParticlesInternals.updaters=t(e.__tsParticlesInternals.updaters),e.__tsParticlesInternals.utils=t(e.__tsParticlesInternals.utils),e.__tsParticlesInternals.canvas=t(e.__tsParticlesInternals.canvas),e.__tsParticlesInternals.path=t(e.__tsParticlesInternals.path),e.tsparticlesInternalExports=e.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/plugin-interactivity","@tsparticles/engine"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).__tsParticlesInternals=e.__tsParticlesInternals||{},e.__tsParticlesInternals.interactions=e.__tsParticlesInternals.interactions||{},e.__tsParticlesInternals.interactions.externalRepulse=e.__tsParticlesInternals.interactions.externalRepulse||{}),e.__tsParticlesInternals.plugins.interactivity,e.__tsParticlesInternals.engine)}(this,function(e,t,s){"use strict";class n{distance=200;duration=.4;easing="ease-out-quad";factor=100;maxSpeed=50;restore;speed=1;constructor(){this.restore={enable:!1,delay:0,speed:.08,follow:!0}}load(e){s.isNull(e)||(s.loadProperty(this,"distance",e.distance),s.loadProperty(this,"duration",e.duration),s.loadProperty(this,"easing",e.easing),s.loadProperty(this,"factor",e.factor),s.loadProperty(this,"speed",e.speed),s.loadProperty(this,"maxSpeed",e.maxSpeed),void 0!==e.restore&&(this.restore.enable=e.restore.enable??this.restore.enable,this.restore.delay=e.restore.delay??this.restore.delay,this.restore.speed=e.restore.speed??this.restore.speed,this.restore.follow=e.restore.follow??this.restore.follow))}}class i extends n{selectors=[];load(e){super.load(e),s.isNull(e)||s.loadProperty(this,"selectors",e.selectors)}}class a extends n{divs;load(e){super.load(e),s.isNull(e)||(this.divs=s.executeOnSingleOrMultiple(e.divs,e=>{const t=new i;return t.load(e),t}))}}const r="repulse";class l extends t.ExternalInteractorBase{handleClickMode;#e;#t;#s;#n;#i;#a;constructor(e,t){super(t),this.#i=e,this.#s=0,this.#n=s.Vector.origin,this.#t=new Set,this.#e=s.Vector.origin,this.#a=new Map,t.repulse??={particles:[]},this.handleClickMode=(e,n)=>{const i=this.container.actualOptions,a=i.interactivity?.modes.repulse;if(!a||e!==r)return;t.repulse??={particles:[]};const l=t.repulse;l.clicking=!0,l.count=0;for(const e of t.repulse.particles)this.isEnabled(n,e)&&e.velocity.setTo(e.initialVelocity);l.particles=[],l.finish=!1,setTimeout(()=>{t.destroyed||(l.clicking=!1)},a.duration*s.millisecondsToSeconds)}}get maxDistance(){return this.#s}clear(){}init(){const e=this.container,t=e.actualOptions.interactivity?.modes.repulse;t&&(this.#s=t.distance,e.retina.repulseModeDistance=t.distance*e.retina.pixelRatio)}interact(e){this.#t.clear();const n=this.container.actualOptions,i=e.status===t.mouseMoveEvent,a=n.interactivity?.events;if(!a)return;const l=a.onHover,o=l.enable,c=l.mode,p=a.onClick,_=p.enable,d=p.mode,u=a.onDiv;i&&o&&s.isInArray(r,c)?this.#r(e):_&&s.isInArray(r,d)?this.#l(e):t.divModeExecute(r,u,(t,s)=>{this.#o(e,t,s)}),this.#c()}isEnabled(e,n){const i=this.container.actualOptions,a=e.mouse,l=(n?.interactivity??i.interactivity)?.events;if(!l)return!1;const o=l.onDiv,c=l.onHover,p=l.onClick,_=t.isDivModeEnabled(r,o);if(!(_||c.enable&&a.position||p.enable&&a.clickPosition))return!1;const d=c.mode,u=p.mode;return s.isInArray(r,d)||s.isInArray(r,u)||_}loadModeOptions(e,...t){s.loadOptionProperty(e,"repulse",a,...t)}reset(){}#l(e){const t=this.container,n=t.actualOptions.interactivity?.modes.repulse;if(!n)return;const i=t.repulse??{particles:[]};if(i.finish||(i.count??=0,i.count++,i.count===t.particles.count&&(i.finish=!0)),i.clicking){const a=t.retina.repulseModeDistance;if(!a||a<0)return;const r=Math.pow(a/6,3),l=e.mouse.clickPosition;if(void 0===l)return;const o=new s.Circle(l.x,l.y,r),c=t.particles.grid.query(o,t=>this.isEnabled(e,t));for(const e of c){const{dx:t,dy:a,distance:o}=s.getDistances(l,e.position),c=o**2,p=-r*n.speed/c;c<=r&&(this.#p(e),i.particles.push(e),this.#e.x=t,this.#e.y=a,this.#e.length=p,e.velocity.setTo(this.#e))}}else if(!1===i.clicking){for(const e of i.particles)e.velocity.setTo(e.initialVelocity);i.particles=[]}}#r(e){const t=this.container,n=e.mouse.position,i=t.retina.repulseModeDistance;!i||i<0||!n||this.#_(e,n,i,new s.Circle(n.x,n.y,i))}#_(e,t,n,i,a){const r=this.container,l=r.particles.grid.query(i,t=>this.isEnabled(e,t)),o=r.actualOptions.interactivity?.modes.repulse;if(!o)return;const{easing:c,speed:p,factor:_,maxSpeed:d}=o,u=this.#i.getEasing(c),h=(a?.speed??p)*_;for(const e of l){const{dx:i,dy:a,distance:r}=s.getDistances(e.position,t),l=s.clamp(u(1-r/n)*h,0,d);this.#n.x=r?i/r*l:h,this.#n.y=r?a/r*l:h,this.#p(e),e.position.addTo(this.#n)}}#c(){const e=this.container.actualOptions.interactivity?.modes.repulse?.restore;if(!e?.enable||!this.#a.size)return;const t=Date.now(),n=e.delay*s.millisecondsToSeconds,i=Math.max(.001,Math.min(1,e.speed));for(const[s,a]of this.#a){if(this.#t.has(s))continue;if(s.destroyed){this.#a.delete(s);continue}const r=a.target;if(t-a.lastInteractionTime<n)continue;e.follow&&s.options.move.enable&&(r.x+=s.velocity.x,r.y+=s.velocity.y,r.z+=s.velocity.z);const l=r.x-s.position.x,o=r.y-s.position.y,c=r.z-s.position.z;s.position.x+=l*i,s.position.y+=o*i,s.position.z+=c*i,Math.abs(l)<=.5&&Math.abs(o)<=.5&&(s.position.x=r.x,s.position.y=r.y,s.position.z=r.z,this.#a.delete(s))}}#o(e,n,i){const a=this.container,r=a.actualOptions.interactivity?.modes.repulse;if(!r)return;const l=s.safeDocument().querySelectorAll(n);l.length&&l.forEach(n=>{const l=n,o=a.retina.pixelRatio,c={x:(l.offsetLeft+l.offsetWidth*s.half)*o,y:(l.offsetTop+l.offsetHeight*s.half)*o},p=l.offsetWidth*s.half*o,_=i.type===t.DivType.circle?new s.Circle(c.x,c.y,p):new s.Rectangle(l.offsetLeft*o,l.offsetTop*o,l.offsetWidth*o,l.offsetHeight*o),d=r.divs,u=t.divMode(d,l);this.#_(e,c,p,_,u)})}#p(e){this.#t.add(e);const t=this.container.actualOptions.interactivity?.modes.repulse?.restore;if(!t?.enable)return;const s=Date.now();let n=this.#a.get(e);n||(n={target:e.position.copy(),lastInteractionTime:s},this.#a.set(e,n)),n.lastInteractionTime=s,t.follow&&e.options.move.enable&&(n.target.x+=e.velocity.x,n.target.y+=e.velocity.y,n.target.z+=e.velocity.z)}}async function o(e){e.checkVersion("4.2.0"),await e.pluginManager.register(e=>{t.ensureInteractivityPluginLoaded(e);const s=e.pluginManager;s.addInteractor?.("externalRepulse",e=>Promise.resolve(new l(s,e)))})}const c=globalThis;c.__tsParticlesInternals=c.__tsParticlesInternals??{},c.loadExternalRepulseInteraction=o,e.Repulse=a,e.RepulseBase=n,e.RepulseDiv=i,e.loadExternalRepulseInteraction=o}),Object.assign(globalThis.window||globalThis,{loadExternalRepulseInteraction:(globalThis.__tsParticlesInternals.interactions.externalRepulse||{}).loadExternalRepulseInteraction}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
@@ -1,9 +1,9 @@
1
- import { EasingType, type EasingTypeAlt, type IOptionLoader, type RecursivePartial } from "@tsparticles/engine";
1
+ import { type IOptionLoader, type RecursivePartial } from "@tsparticles/engine";
2
2
  import type { IRepulseBase, IRepulseRestore } from "../Interfaces/IRepulseBase.js";
3
3
  export declare abstract class RepulseBase implements IRepulseBase, IOptionLoader<IRepulseBase> {
4
4
  distance: number;
5
5
  duration: number;
6
- easing: EasingType | EasingTypeAlt;
6
+ easing: string;
7
7
  factor: number;
8
8
  maxSpeed: number;
9
9
  restore: IRepulseRestore;
@@ -3,6 +3,5 @@ import type { IRepulseDiv } from "../Interfaces/IRepulseDiv.js";
3
3
  import { RepulseBase } from "./RepulseBase.js";
4
4
  export declare class RepulseDiv extends RepulseBase implements IRepulseDiv, IOptionLoader<IRepulseDiv> {
5
5
  selectors: SingleOrMultiple<string>;
6
- constructor();
7
6
  load(data?: RecursivePartial<IRepulseDiv>): void;
8
7
  }
@@ -1,7 +1,9 @@
1
1
  import type { InteractivityOptions } from "@tsparticles/plugin-interactivity";
2
- import type { RepulseMode } from "../../Types.js";
2
+ import type { Repulse } from "./Repulse.js";
3
3
  export type RepulseOptions = InteractivityOptions & {
4
4
  interactivity?: {
5
- modes: RepulseMode;
5
+ modes: {
6
+ repulse?: Repulse;
7
+ };
6
8
  };
7
9
  };
@@ -1,4 +1,3 @@
1
- import type { EasingType, EasingTypeAlt } from "@tsparticles/engine";
2
1
  export interface IRepulseRestore {
3
2
  delay: number;
4
3
  enable: boolean;
@@ -8,7 +7,7 @@ export interface IRepulseRestore {
8
7
  export interface IRepulseBase {
9
8
  distance: number;
10
9
  duration: number;
11
- easing: EasingType | EasingTypeAlt;
10
+ easing: string;
12
11
  factor: number;
13
12
  maxSpeed: number;
14
13
  restore: IRepulseRestore;