@tsparticles/interaction-external-bounce 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,5 +1,5 @@
1
1
  import { ExternalInteractorBase, isDivModeEnabled, mouseMoveEvent, } from "@tsparticles/plugin-interactivity";
2
- import { isInArray } from "@tsparticles/engine";
2
+ import { isInArray, loadOptionProperty } from "@tsparticles/engine";
3
3
  import { divBounce, mouseBounce } from "./Utils.js";
4
4
  import { Bounce } from "./Options/Classes/Bounce.js";
5
5
  const bounceMode = "bounce";
@@ -45,10 +45,7 @@ export class Bouncer extends ExternalInteractorBase {
45
45
  isDivModeEnabled(bounceMode, divs));
46
46
  }
47
47
  loadModeOptions(options, ...sources) {
48
- options.bounce ??= new Bounce();
49
- for (const source of sources) {
50
- options.bounce.load(source?.bounce);
51
- }
48
+ loadOptionProperty(options, "bounce", Bounce, ...sources);
52
49
  }
53
50
  reset() {
54
51
  }
@@ -1,15 +1,10 @@
1
- import { isNull } from "@tsparticles/engine";
1
+ import { isNull, loadProperty } from "@tsparticles/engine";
2
2
  export class Bounce {
3
- distance;
4
- constructor() {
5
- this.distance = 200;
6
- }
3
+ distance = 200;
7
4
  load(data) {
8
5
  if (isNull(data)) {
9
6
  return;
10
7
  }
11
- if (data.distance !== undefined) {
12
- this.distance = data.distance;
13
- }
8
+ loadProperty(this, "distance", data.distance);
14
9
  }
15
10
  }
package/browser/Utils.js CHANGED
@@ -1,6 +1,6 @@
1
- import { Circle, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, double, getRangeValue, half, safeDocument, } from "@tsparticles/engine";
1
+ import { Circle, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, double, getRangeValue, half, minRadius, minVelocity, safeDocument, squareExp, } from "@tsparticles/engine";
2
2
  import { DivType, divModeExecute } from "@tsparticles/plugin-interactivity";
3
- const squareExp = 2, halfPI = Math.PI * half, toleranceFactor = 10, minRadius = 0, minVelocity = 0;
3
+ const halfPI = Math.PI * half, toleranceFactor = 10;
4
4
  function processBounce(container, position, radius, area, enabledCb) {
5
5
  const query = container.particles.grid.query(area, enabledCb);
6
6
  for (const particle of query) {
package/browser/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ensureInteractivityPluginLoaded } from "@tsparticles/plugin-interactivity";
2
2
  import { Bouncer } from "./Bouncer.js";
3
3
  export async function loadExternalBounceInteraction(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?.("externalBounce", container => {
@@ -1,5 +1,5 @@
1
1
  export async function loadExternalBounceInteraction(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/cjs/Bouncer.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ExternalInteractorBase, isDivModeEnabled, mouseMoveEvent, } from "@tsparticles/plugin-interactivity";
2
- import { isInArray } from "@tsparticles/engine";
2
+ import { isInArray, loadOptionProperty } from "@tsparticles/engine";
3
3
  import { divBounce, mouseBounce } from "./Utils.js";
4
4
  import { Bounce } from "./Options/Classes/Bounce.js";
5
5
  const bounceMode = "bounce";
@@ -45,10 +45,7 @@ export class Bouncer extends ExternalInteractorBase {
45
45
  isDivModeEnabled(bounceMode, divs));
46
46
  }
47
47
  loadModeOptions(options, ...sources) {
48
- options.bounce ??= new Bounce();
49
- for (const source of sources) {
50
- options.bounce.load(source?.bounce);
51
- }
48
+ loadOptionProperty(options, "bounce", Bounce, ...sources);
52
49
  }
53
50
  reset() {
54
51
  }
@@ -1,15 +1,10 @@
1
- import { isNull } from "@tsparticles/engine";
1
+ import { isNull, loadProperty } from "@tsparticles/engine";
2
2
  export class Bounce {
3
- distance;
4
- constructor() {
5
- this.distance = 200;
6
- }
3
+ distance = 200;
7
4
  load(data) {
8
5
  if (isNull(data)) {
9
6
  return;
10
7
  }
11
- if (data.distance !== undefined) {
12
- this.distance = data.distance;
13
- }
8
+ loadProperty(this, "distance", data.distance);
14
9
  }
15
10
  }
package/cjs/Utils.js CHANGED
@@ -1,6 +1,6 @@
1
- import { Circle, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, double, getRangeValue, half, safeDocument, } from "@tsparticles/engine";
1
+ import { Circle, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, double, getRangeValue, half, minRadius, minVelocity, safeDocument, squareExp, } from "@tsparticles/engine";
2
2
  import { DivType, divModeExecute } from "@tsparticles/plugin-interactivity";
3
- const squareExp = 2, halfPI = Math.PI * half, toleranceFactor = 10, minRadius = 0, minVelocity = 0;
3
+ const halfPI = Math.PI * half, toleranceFactor = 10;
4
4
  function processBounce(container, position, radius, area, enabledCb) {
5
5
  const query = container.particles.grid.query(area, enabledCb);
6
6
  for (const particle of query) {
package/cjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ensureInteractivityPluginLoaded } from "@tsparticles/plugin-interactivity";
2
2
  import { Bouncer } from "./Bouncer.js";
3
3
  export async function loadExternalBounceInteraction(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?.("externalBounce", container => {
package/cjs/index.lazy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export async function loadExternalBounceInteraction(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/esm/Bouncer.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ExternalInteractorBase, isDivModeEnabled, mouseMoveEvent, } from "@tsparticles/plugin-interactivity";
2
- import { isInArray } from "@tsparticles/engine";
2
+ import { isInArray, loadOptionProperty } from "@tsparticles/engine";
3
3
  import { divBounce, mouseBounce } from "./Utils.js";
4
4
  import { Bounce } from "./Options/Classes/Bounce.js";
5
5
  const bounceMode = "bounce";
@@ -45,10 +45,7 @@ export class Bouncer extends ExternalInteractorBase {
45
45
  isDivModeEnabled(bounceMode, divs));
46
46
  }
47
47
  loadModeOptions(options, ...sources) {
48
- options.bounce ??= new Bounce();
49
- for (const source of sources) {
50
- options.bounce.load(source?.bounce);
51
- }
48
+ loadOptionProperty(options, "bounce", Bounce, ...sources);
52
49
  }
53
50
  reset() {
54
51
  }
@@ -1,15 +1,10 @@
1
- import { isNull } from "@tsparticles/engine";
1
+ import { isNull, loadProperty } from "@tsparticles/engine";
2
2
  export class Bounce {
3
- distance;
4
- constructor() {
5
- this.distance = 200;
6
- }
3
+ distance = 200;
7
4
  load(data) {
8
5
  if (isNull(data)) {
9
6
  return;
10
7
  }
11
- if (data.distance !== undefined) {
12
- this.distance = data.distance;
13
- }
8
+ loadProperty(this, "distance", data.distance);
14
9
  }
15
10
  }
package/esm/Utils.js CHANGED
@@ -1,6 +1,6 @@
1
- import { Circle, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, double, getRangeValue, half, safeDocument, } from "@tsparticles/engine";
1
+ import { Circle, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, double, getRangeValue, half, minRadius, minVelocity, safeDocument, squareExp, } from "@tsparticles/engine";
2
2
  import { DivType, divModeExecute } from "@tsparticles/plugin-interactivity";
3
- const squareExp = 2, halfPI = Math.PI * half, toleranceFactor = 10, minRadius = 0, minVelocity = 0;
3
+ const halfPI = Math.PI * half, toleranceFactor = 10;
4
4
  function processBounce(container, position, radius, area, enabledCb) {
5
5
  const query = container.particles.grid.query(area, enabledCb);
6
6
  for (const particle of query) {
package/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ensureInteractivityPluginLoaded } from "@tsparticles/plugin-interactivity";
2
2
  import { Bouncer } from "./Bouncer.js";
3
3
  export async function loadExternalBounceInteraction(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?.("externalBounce", container => {
package/esm/index.lazy.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export async function loadExternalBounceInteraction(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-external-bounce",
3
- "version": "4.1.2",
3
+ "version": "4.2.0",
4
4
  "description": "tsParticles bounce 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.2",
101
- "@tsparticles/plugin-interactivity": "4.1.2"
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.bounce.js","children":[{"name":"dist/browser","children":[{"uid":"94b27219-1","name":"Utils.js"},{"name":"Options/Classes/Bounce.js","uid":"94b27219-3"},{"uid":"94b27219-5","name":"Bouncer.js"},{"uid":"94b27219-7","name":"index.js"},{"uid":"94b27219-9","name":"browser.js"}]}]}],"isRoot":true},"nodeParts":{"94b27219-1":{"renderedLength":5363,"gzipLength":0,"brotliLength":0,"metaUid":"94b27219-0"},"94b27219-3":{"renderedLength":325,"gzipLength":0,"brotliLength":0,"metaUid":"94b27219-2"},"94b27219-5":{"renderedLength":2254,"gzipLength":0,"brotliLength":0,"metaUid":"94b27219-4"},"94b27219-7":{"renderedLength":392,"gzipLength":0,"brotliLength":0,"metaUid":"94b27219-6"},"94b27219-9":{"renderedLength":201,"gzipLength":0,"brotliLength":0,"metaUid":"94b27219-8"}},"nodeMetas":{"94b27219-0":{"id":"/dist/browser/Utils.js","moduleParts":{"tsparticles.interaction.external.bounce.js":"94b27219-1"},"imported":[{"uid":"94b27219-11"},{"uid":"94b27219-10"}],"importedBy":[{"uid":"94b27219-4"}]},"94b27219-2":{"id":"/dist/browser/Options/Classes/Bounce.js","moduleParts":{"tsparticles.interaction.external.bounce.js":"94b27219-3"},"imported":[{"uid":"94b27219-11"}],"importedBy":[{"uid":"94b27219-6"},{"uid":"94b27219-4"}]},"94b27219-4":{"id":"/dist/browser/Bouncer.js","moduleParts":{"tsparticles.interaction.external.bounce.js":"94b27219-5"},"imported":[{"uid":"94b27219-10"},{"uid":"94b27219-11"},{"uid":"94b27219-0"},{"uid":"94b27219-2"}],"importedBy":[{"uid":"94b27219-6"}]},"94b27219-6":{"id":"/dist/browser/index.js","moduleParts":{"tsparticles.interaction.external.bounce.js":"94b27219-7"},"imported":[{"uid":"94b27219-10"},{"uid":"94b27219-4"},{"uid":"94b27219-2"}],"importedBy":[{"uid":"94b27219-8"}]},"94b27219-8":{"id":"/dist/browser/browser.js","moduleParts":{"tsparticles.interaction.external.bounce.js":"94b27219-9"},"imported":[{"uid":"94b27219-6"}],"importedBy":[],"isEntry":true},"94b27219-10":{"id":"@tsparticles/plugin-interactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"94b27219-6"},{"uid":"94b27219-4"},{"uid":"94b27219-0"}],"isExternal":true},"94b27219-11":{"id":"@tsparticles/engine","moduleParts":{},"imported":[],"importedBy":[{"uid":"94b27219-4"},{"uid":"94b27219-2"},{"uid":"94b27219-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.external.bounce.js","children":[{"name":"dist/browser","children":[{"uid":"a8911fbe-1","name":"Utils.js"},{"name":"Options/Classes/Bounce.js","uid":"a8911fbe-3"},{"uid":"a8911fbe-5","name":"Bouncer.js"},{"uid":"a8911fbe-7","name":"index.js"},{"uid":"a8911fbe-9","name":"browser.js"}]}]}],"isRoot":true},"nodeParts":{"a8911fbe-1":{"renderedLength":5344,"gzipLength":0,"brotliLength":0,"metaUid":"a8911fbe-0"},"a8911fbe-3":{"renderedLength":222,"gzipLength":0,"brotliLength":0,"metaUid":"a8911fbe-2"},"a8911fbe-5":{"renderedLength":2176,"gzipLength":0,"brotliLength":0,"metaUid":"a8911fbe-4"},"a8911fbe-7":{"renderedLength":392,"gzipLength":0,"brotliLength":0,"metaUid":"a8911fbe-6"},"a8911fbe-9":{"renderedLength":201,"gzipLength":0,"brotliLength":0,"metaUid":"a8911fbe-8"}},"nodeMetas":{"a8911fbe-0":{"id":"/dist/browser/Utils.js","moduleParts":{"tsparticles.interaction.external.bounce.js":"a8911fbe-1"},"imported":[{"uid":"a8911fbe-11"},{"uid":"a8911fbe-10"}],"importedBy":[{"uid":"a8911fbe-4"}]},"a8911fbe-2":{"id":"/dist/browser/Options/Classes/Bounce.js","moduleParts":{"tsparticles.interaction.external.bounce.js":"a8911fbe-3"},"imported":[{"uid":"a8911fbe-11"}],"importedBy":[{"uid":"a8911fbe-6"},{"uid":"a8911fbe-4"}]},"a8911fbe-4":{"id":"/dist/browser/Bouncer.js","moduleParts":{"tsparticles.interaction.external.bounce.js":"a8911fbe-5"},"imported":[{"uid":"a8911fbe-10"},{"uid":"a8911fbe-11"},{"uid":"a8911fbe-0"},{"uid":"a8911fbe-2"}],"importedBy":[{"uid":"a8911fbe-6"}]},"a8911fbe-6":{"id":"/dist/browser/index.js","moduleParts":{"tsparticles.interaction.external.bounce.js":"a8911fbe-7"},"imported":[{"uid":"a8911fbe-10"},{"uid":"a8911fbe-4"},{"uid":"a8911fbe-2"}],"importedBy":[{"uid":"a8911fbe-8"}]},"a8911fbe-8":{"id":"/dist/browser/browser.js","moduleParts":{"tsparticles.interaction.external.bounce.js":"a8911fbe-9"},"imported":[{"uid":"a8911fbe-6"}],"importedBy":[],"isEntry":true},"a8911fbe-10":{"id":"@tsparticles/plugin-interactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"a8911fbe-6"},{"uid":"a8911fbe-4"},{"uid":"a8911fbe-0"}],"isExternal":true},"a8911fbe-11":{"id":"@tsparticles/engine","moduleParts":{},"imported":[],"importedBy":[{"uid":"a8911fbe-4"},{"uid":"a8911fbe-2"},{"uid":"a8911fbe-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,12 +1,12 @@
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.2 */
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) :
6
6
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.__tsParticlesInternals = global.__tsParticlesInternals || {}, global.__tsParticlesInternals.interactions = global.__tsParticlesInternals.interactions || {}, global.__tsParticlesInternals.interactions.externalBounce = global.__tsParticlesInternals.interactions.externalBounce || {}), global.__tsParticlesInternals.plugins.interactivity, global.__tsParticlesInternals.engine));
7
7
  })(this, (function (exports, pluginInteractivity, engine) { 'use strict';
8
8
 
9
- const squareExp = 2, halfPI = Math.PI * engine.half, toleranceFactor = 10, minRadius = 0, minVelocity = 0;
9
+ const halfPI = Math.PI * engine.half, toleranceFactor = 10;
10
10
  function processBounce(container, position, radius, area, enabledCb) {
11
11
  const query = container.particles.grid.query(area, enabledCb);
12
12
  for (const particle of query) {
@@ -14,7 +14,7 @@
14
14
  engine.circleBounce(engine.circleBounceDataFromParticle(particle), {
15
15
  position,
16
16
  radius,
17
- mass: radius ** squareExp * halfPI,
17
+ mass: radius ** engine.squareExp * halfPI,
18
18
  velocity: engine.Vector.origin,
19
19
  factor: engine.Vector.origin,
20
20
  });
@@ -48,7 +48,7 @@
48
48
  }
49
49
  function mouseBounce(container, interactivityData, enabledCb) {
50
50
  const pxRatio = container.retina.pixelRatio, tolerance = toleranceFactor * pxRatio, mousePos = interactivityData.mouse.position, radius = container.retina.bounceModeDistance;
51
- if (!radius || radius < minRadius || !mousePos) {
51
+ if (!radius || radius < engine.minRadius || !mousePos) {
52
52
  return;
53
53
  }
54
54
  processBounce(container, mousePos, radius, new engine.Circle(mousePos.x, mousePos.y, radius + tolerance), enabledCb);
@@ -61,8 +61,8 @@
61
61
  pOtherSide.max > rectOtherSide.max) {
62
62
  return res;
63
63
  }
64
- if ((pSide.max >= rectSide.min && pSide.max <= (rectSide.max + rectSide.min) * engine.half && velocity > minVelocity) ||
65
- (pSide.min <= rectSide.max && pSide.min > (rectSide.max + rectSide.min) * engine.half && velocity < minVelocity)) {
64
+ if ((pSide.max >= rectSide.min && pSide.max <= (rectSide.max + rectSide.min) * engine.half && velocity > engine.minVelocity) ||
65
+ (pSide.min <= rectSide.max && pSide.min > (rectSide.max + rectSide.min) * engine.half && velocity < engine.minVelocity)) {
66
66
  res.velocity = velocity * -factor;
67
67
  res.bounced = true;
68
68
  }
@@ -128,17 +128,12 @@
128
128
  }
129
129
 
130
130
  class Bounce {
131
- distance;
132
- constructor() {
133
- this.distance = 200;
134
- }
131
+ distance = 200;
135
132
  load(data) {
136
133
  if (engine.isNull(data)) {
137
134
  return;
138
135
  }
139
- if (data.distance !== undefined) {
140
- this.distance = data.distance;
141
- }
136
+ engine.loadProperty(this, "distance", data.distance);
142
137
  }
143
138
  }
144
139
 
@@ -185,17 +180,14 @@
185
180
  pluginInteractivity.isDivModeEnabled(bounceMode, divs));
186
181
  }
187
182
  loadModeOptions(options, ...sources) {
188
- options.bounce ??= new Bounce();
189
- for (const source of sources) {
190
- options.bounce.load(source?.bounce);
191
- }
183
+ engine.loadOptionProperty(options, "bounce", Bounce, ...sources);
192
184
  }
193
185
  reset() {
194
186
  }
195
187
  }
196
188
 
197
189
  async function loadExternalBounceInteraction(engine) {
198
- engine.checkVersion("4.1.2");
190
+ engine.checkVersion("4.2.0");
199
191
  await engine.pluginManager.register((e) => {
200
192
  pluginInteractivity.ensureInteractivityPluginLoaded(e);
201
193
  e.pluginManager.addInteractor?.("externalBounce", 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 e="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,e){return e in t||(t[e]={}),t[e]}})}:function(t){return t};t.__tsParticlesInternals.bundles=e(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=e(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=e(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=e(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=e(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=e(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=e(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=e(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=e(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=e(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=e(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=e(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=e(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/plugin-interactivity","@tsparticles/engine"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.interactions.externalBounce=t.__tsParticlesInternals.interactions.externalBounce||{}),t.__tsParticlesInternals.plugins.interactivity,t.__tsParticlesInternals.engine)}(this,function(t,e,s){"use strict";const n=Math.PI*s.half;function a(t,e,a,i,r){const c=t.particles.grid.query(i,r);for(const t of c)i instanceof s.Circle?s.circleBounce(s.circleBounceDataFromParticle(t),{position:e,radius:a,mass:a**2*n,velocity:s.Vector.origin,factor:s.Vector.origin}):i instanceof s.Rectangle&&l(t,s.calculateBounds(e,a))}function i(t,n,i,r){e.divModeExecute(i,n,(n,i)=>{!function(t,n,a,i){const r=s.safeDocument().querySelectorAll(n);r.length&&r.forEach(n=>{const r=n,l=t.retina.pixelRatio,c={x:(r.offsetLeft+r.offsetWidth*s.half)*l,y:(r.offsetTop+r.offsetHeight*s.half)*l},o=r.offsetWidth*s.half*l,_=10*l,u=a.type===e.DivType.circle?new s.Circle(c.x,c.y,o+_):new s.Rectangle(r.offsetLeft*l-_,r.offsetTop*l-_,r.offsetWidth*l+_*s.double,r.offsetHeight*l+_*s.double);i(c,o,u)})}(t,n,i,(e,s,n)=>{a(t,e,s,n,r)})})}function r(t){const e={bounced:!1},{pSide:n,pOtherSide:a,rectSide:i,rectOtherSide:r,velocity:l,factor:c}=t;return a.min<r.min||a.min>r.max||a.max<r.min||a.max>r.max||(n.max>=i.min&&n.max<=(i.max+i.min)*s.half&&l>0||n.min<=i.max&&n.min>(i.max+i.min)*s.half&&l<0)&&(e.velocity=l*-c,e.bounced=!0),e}function l(t,e){const n=t.getPosition(),a=t.getRadius(),i=s.calculateBounds(n,a),l=t.options.bounce,c=r({pSide:{min:i.left,max:i.right},pOtherSide:{min:i.top,max:i.bottom},rectSide:{min:e.left,max:e.right},rectOtherSide:{min:e.top,max:e.bottom},velocity:t.velocity.x,factor:s.getRangeValue(l.horizontal.value)});c.bounced&&(void 0!==c.velocity&&(t.velocity.x=c.velocity),void 0!==c.position&&(t.position.x=c.position));const o=r({pSide:{min:i.top,max:i.bottom},pOtherSide:{min:i.left,max:i.right},rectSide:{min:e.top,max:e.bottom},rectOtherSide:{min:e.left,max:e.right},velocity:t.velocity.y,factor:s.getRangeValue(l.vertical.value)});o.bounced&&(void 0!==o.velocity&&(t.velocity.y=o.velocity),void 0!==o.position&&(t.position.y=o.position))}class c{distance;constructor(){this.distance=200}load(t){s.isNull(t)||void 0!==t.distance&&(this.distance=t.distance)}}const o="bounce";class _ extends e.ExternalInteractorBase{#t;constructor(t){super(t),this.#t=0}get maxDistance(){return this.#t}clear(){}init(){const t=this.container,e=t.actualOptions.interactivity?.modes.bounce;e&&(this.#t=e.distance,t.retina.bounceModeDistance=e.distance*t.retina.pixelRatio)}interact(t){const n=this.container.actualOptions,r=n.interactivity?.events,l=t.status===e.mouseMoveEvent;if(!r)return;const c=r.onHover.enable,_=r.onHover.mode,u=r.onDiv;l&&c&&s.isInArray(o,_)?function(t,e,n){const i=10*t.retina.pixelRatio,r=e.mouse.position,l=t.retina.bounceModeDistance;!l||l<0||!r||a(t,r,l,new s.Circle(r.x,r.y,l+i),n)}(this.container,t,e=>this.isEnabled(t,e)):i(this.container,u,o,e=>this.isEnabled(t,e))}isEnabled(t,n){const a=this.container.actualOptions,i=t.mouse,r=(n?.interactivity??a.interactivity)?.events;if(!r)return!1;const l=r.onDiv;return!!i.position&&r.onHover.enable&&s.isInArray(o,r.onHover.mode)||e.isDivModeEnabled(o,l)}loadModeOptions(t,...e){t.bounce??=new c;for(const s of e)t.bounce.load(s?.bounce)}reset(){}}async function u(t){t.checkVersion("4.1.2"),await t.pluginManager.register(t=>{e.ensureInteractivityPluginLoaded(t),t.pluginManager.addInteractor?.("externalBounce",t=>Promise.resolve(new _(t)))})}const p=globalThis;p.__tsParticlesInternals=p.__tsParticlesInternals??{},p.loadExternalBounceInteraction=u,t.Bounce=c,t.loadExternalBounceInteraction=u}),Object.assign(globalThis.window||globalThis,{loadExternalBounceInteraction:(globalThis.__tsParticlesInternals.interactions.externalBounce||{}).loadExternalBounceInteraction}),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 e="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,e){return e in t||(t[e]={}),t[e]}})}:function(t){return t};t.__tsParticlesInternals.bundles=e(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=e(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=e(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=e(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=e(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=e(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=e(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=e(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=e(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=e(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=e(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=e(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=e(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/plugin-interactivity","@tsparticles/engine"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.interactions.externalBounce=t.__tsParticlesInternals.interactions.externalBounce||{}),t.__tsParticlesInternals.plugins.interactivity,t.__tsParticlesInternals.engine)}(this,function(t,e,s){"use strict";const n=Math.PI*s.half;function a(t,e,a,i,r){const c=t.particles.grid.query(i,r);for(const t of c)i instanceof s.Circle?s.circleBounce(s.circleBounceDataFromParticle(t),{position:e,radius:a,mass:a**s.squareExp*n,velocity:s.Vector.origin,factor:s.Vector.origin}):i instanceof s.Rectangle&&l(t,s.calculateBounds(e,a))}function i(t,n,i,r){e.divModeExecute(i,n,(n,i)=>{!function(t,n,a,i){const r=s.safeDocument().querySelectorAll(n);r.length&&r.forEach(n=>{const r=n,l=t.retina.pixelRatio,c={x:(r.offsetLeft+r.offsetWidth*s.half)*l,y:(r.offsetTop+r.offsetHeight*s.half)*l},o=r.offsetWidth*s.half*l,_=10*l,u=a.type===e.DivType.circle?new s.Circle(c.x,c.y,o+_):new s.Rectangle(r.offsetLeft*l-_,r.offsetTop*l-_,r.offsetWidth*l+_*s.double,r.offsetHeight*l+_*s.double);i(c,o,u)})}(t,n,i,(e,s,n)=>{a(t,e,s,n,r)})})}function r(t){const e={bounced:!1},{pSide:n,pOtherSide:a,rectSide:i,rectOtherSide:r,velocity:l,factor:c}=t;return a.min<r.min||a.min>r.max||a.max<r.min||a.max>r.max||(n.max>=i.min&&n.max<=(i.max+i.min)*s.half&&l>s.minVelocity||n.min<=i.max&&n.min>(i.max+i.min)*s.half&&l<s.minVelocity)&&(e.velocity=l*-c,e.bounced=!0),e}function l(t,e){const n=t.getPosition(),a=t.getRadius(),i=s.calculateBounds(n,a),l=t.options.bounce,c=r({pSide:{min:i.left,max:i.right},pOtherSide:{min:i.top,max:i.bottom},rectSide:{min:e.left,max:e.right},rectOtherSide:{min:e.top,max:e.bottom},velocity:t.velocity.x,factor:s.getRangeValue(l.horizontal.value)});c.bounced&&(void 0!==c.velocity&&(t.velocity.x=c.velocity),void 0!==c.position&&(t.position.x=c.position));const o=r({pSide:{min:i.top,max:i.bottom},pOtherSide:{min:i.left,max:i.right},rectSide:{min:e.top,max:e.bottom},rectOtherSide:{min:e.left,max:e.right},velocity:t.velocity.y,factor:s.getRangeValue(l.vertical.value)});o.bounced&&(void 0!==o.velocity&&(t.velocity.y=o.velocity),void 0!==o.position&&(t.position.y=o.position))}class c{distance=200;load(t){s.isNull(t)||s.loadProperty(this,"distance",t.distance)}}const o="bounce";class _ extends e.ExternalInteractorBase{#t;constructor(t){super(t),this.#t=0}get maxDistance(){return this.#t}clear(){}init(){const t=this.container,e=t.actualOptions.interactivity?.modes.bounce;e&&(this.#t=e.distance,t.retina.bounceModeDistance=e.distance*t.retina.pixelRatio)}interact(t){const n=this.container.actualOptions,r=n.interactivity?.events,l=t.status===e.mouseMoveEvent;if(!r)return;const c=r.onHover.enable,_=r.onHover.mode,u=r.onDiv;l&&c&&s.isInArray(o,_)?function(t,e,n){const i=10*t.retina.pixelRatio,r=e.mouse.position,l=t.retina.bounceModeDistance;!l||l<s.minRadius||!r||a(t,r,l,new s.Circle(r.x,r.y,l+i),n)}(this.container,t,e=>this.isEnabled(t,e)):i(this.container,u,o,e=>this.isEnabled(t,e))}isEnabled(t,n){const a=this.container.actualOptions,i=t.mouse,r=(n?.interactivity??a.interactivity)?.events;if(!r)return!1;const l=r.onDiv;return!!i.position&&r.onHover.enable&&s.isInArray(o,r.onHover.mode)||e.isDivModeEnabled(o,l)}loadModeOptions(t,...e){s.loadOptionProperty(t,"bounce",c,...e)}reset(){}}async function u(t){t.checkVersion("4.2.0"),await t.pluginManager.register(t=>{e.ensureInteractivityPluginLoaded(t),t.pluginManager.addInteractor?.("externalBounce",t=>Promise.resolve(new _(t)))})}const p=globalThis;p.__tsParticlesInternals=p.__tsParticlesInternals??{},p.loadExternalBounceInteraction=u,t.Bounce=c,t.loadExternalBounceInteraction=u}),Object.assign(globalThis.window||globalThis,{loadExternalBounceInteraction:(globalThis.__tsParticlesInternals.interactions.externalBounce||{}).loadExternalBounceInteraction}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
@@ -2,6 +2,5 @@ import { type IOptionLoader, type RecursivePartial } from "@tsparticles/engine";
2
2
  import type { IBounce } from "../Interfaces/IBounce.js";
3
3
  export declare class Bounce implements IBounce, IOptionLoader<IBounce> {
4
4
  distance: number;
5
- constructor();
6
5
  load(data?: RecursivePartial<IBounce>): void;
7
6
  }
@@ -1,7 +1,9 @@
1
- import type { BounceMode } from "../../Types.js";
1
+ import type { Bounce } from "./Bounce.js";
2
2
  import type { InteractivityOptions } from "@tsparticles/plugin-interactivity";
3
3
  export type BounceOptions = InteractivityOptions & {
4
4
  interactivity?: {
5
- modes: BounceMode;
5
+ modes: {
6
+ bounce?: Bounce;
7
+ };
6
8
  };
7
9
  };