@tsparticles/interaction-particles-attract 4.0.0-beta.0 → 4.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/13.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_interaction_particles_attract=this.webpackChunk_tsparticles_interaction_particles_attract||[]).push([[13],{13(t,e,a){a.d(e,{Attractor:()=>c});var i=a(303);class s{distance;enable;rotate;constructor(){this.distance=200,this.enable=!1,this.rotate={x:3e3,y:3e3}}load(t){if(!(0,i.isNull)(t)&&(void 0!==t.distance&&(this.distance=(0,i.setRangeValue)(t.distance)),void 0!==t.enable&&(this.enable=t.enable),t.rotate)){let e=t.rotate.x;void 0!==e&&(this.rotate.x=e);let a=t.rotate.y;void 0!==a&&(this.rotate.y=a)}}}var r=a(702);class c extends r.ParticlesInteractorBase{_maxDistance;constructor(t){super(t),this._maxDistance=0}get maxDistance(){return this._maxDistance}clear(){}init(){}interact(t){if(!t.options.attract?.enable)return;let e=this.container;if((0,i.isNull)(t.attractDistance)){let a=(0,i.getRangeValue)(t.options.attract.distance);a>this._maxDistance&&(this._maxDistance=a),t.attractDistance=a*e.retina.pixelRatio}let a=t.attractDistance,s=t.getPosition();for(let r of e.particles.grid.queryCircle(s,a)){if(t===r||!r.options.attract?.enable||r.destroyed||r.spawning)continue;let e=r.getPosition(),{dx:a,dy:c}=(0,i.getDistances)(s,e),n=t.options.attract.rotate,o=a/(1e3*n.x),l=c/(1e3*n.y),d=r.size.value/t.size.value,u=1/d;t.velocity.x-=o*d,t.velocity.y-=l*d,r.velocity.x+=o*u,r.velocity.y+=l*u}}isEnabled(t){return t.options.attract?.enable??!1}loadParticlesOptions(t,...e){for(let a of(t.attract??=new s,e))t.attract.load(a?.attract)}reset(){}}}}]);
package/README.md CHANGED
@@ -8,6 +8,12 @@
8
8
 
9
9
  [tsParticles](https://github.com/tsparticles/tsparticles) interaction plugin for attract effect between particles.
10
10
 
11
+ ## Quick checklist
12
+
13
+ 1. Install `@tsparticles/engine` (or use the CDN bundle below)
14
+ 2. Call the package loader function(s) before `tsParticles.load(...)`
15
+ 3. Apply the package options in your `tsParticles.load(...)` config
16
+
11
17
  ## How to use it
12
18
 
13
19
  ### CDN / Vanilla JS / jQuery
@@ -78,3 +84,28 @@ import { loadParticlesAttractInteraction } from "@tsparticles/interaction-partic
78
84
  await loadParticlesAttractInteraction(tsParticles);
79
85
  })();
80
86
  ```
87
+
88
+ ## Option mapping
89
+
90
+ - Primary options key: `particles.attract`
91
+
92
+ ```json
93
+ {
94
+ "particles": {
95
+ "attract": {
96
+ "enable": true
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
102
+ ## Common pitfalls
103
+
104
+ - Calling `tsParticles.load(...)` before `loadInteractivityPlugin(...)`
105
+ - Verify required peer packages before enabling advanced options
106
+ - Change one option group at a time to isolate regressions quickly
107
+
108
+ ## Related docs
109
+
110
+ - All packages catalog: <https://github.com/tsparticles/tsparticles>
111
+ - Main docs: <https://particles.js.org/docs/>
package/browser/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export async function loadParticlesAttractInteraction(engine) {
2
- engine.checkVersion("4.0.0-beta.0");
3
- await engine.register(async (e) => {
2
+ engine.checkVersion("4.0.0-beta.10");
3
+ await engine.pluginManager.register(async (e) => {
4
4
  const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
5
5
  ensureInteractivityPluginLoaded(e);
6
- e.addInteractor?.("particlesAttract", async (container) => {
6
+ e.pluginManager.addInteractor?.("particlesAttract", async (container) => {
7
7
  const { Attractor } = await import("./Attractor.js");
8
8
  return new Attractor(container);
9
9
  });
package/cjs/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export async function loadParticlesAttractInteraction(engine) {
2
- engine.checkVersion("4.0.0-beta.0");
3
- await engine.register(async (e) => {
2
+ engine.checkVersion("4.0.0-beta.10");
3
+ await engine.pluginManager.register(async (e) => {
4
4
  const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
5
5
  ensureInteractivityPluginLoaded(e);
6
- e.addInteractor?.("particlesAttract", async (container) => {
6
+ e.pluginManager.addInteractor?.("particlesAttract", async (container) => {
7
7
  const { Attractor } = await import("./Attractor.js");
8
8
  return new Attractor(container);
9
9
  });
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v4.0.0-beta.0
7
+ * v4.0.0-beta.10
8
8
  */
9
9
  "use strict";
10
10
  /*
package/esm/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export async function loadParticlesAttractInteraction(engine) {
2
- engine.checkVersion("4.0.0-beta.0");
3
- await engine.register(async (e) => {
2
+ engine.checkVersion("4.0.0-beta.10");
3
+ await engine.pluginManager.register(async (e) => {
4
4
  const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
5
5
  ensureInteractivityPluginLoaded(e);
6
- e.addInteractor?.("particlesAttract", async (container) => {
6
+ e.pluginManager.addInteractor?.("particlesAttract", async (container) => {
7
7
  const { Attractor } = await import("./Attractor.js");
8
8
  return new Attractor(container);
9
9
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/interaction-particles-attract",
3
- "version": "4.0.0-beta.0",
3
+ "version": "4.0.0-beta.10",
4
4
  "description": "tsParticles attract particles interaction",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -81,14 +81,13 @@
81
81
  "browser": "./browser/index.js",
82
82
  "import": "./esm/index.js",
83
83
  "require": "./cjs/index.js",
84
- "umd": "./umd/index.js",
85
- "default": "./cjs/index.js"
84
+ "default": "./esm/index.js"
86
85
  },
87
86
  "./package.json": "./package.json"
88
87
  },
89
- "dependencies": {
90
- "@tsparticles/engine": "4.0.0-beta.0",
91
- "@tsparticles/plugin-interactivity": "4.0.0-beta.0"
88
+ "peerDependencies": {
89
+ "@tsparticles/engine": "4.0.0-beta.10",
90
+ "@tsparticles/plugin-interactivity": "4.0.0-beta.10"
92
91
  },
93
92
  "publishConfig": {
94
93
  "access": "public"