@tsparticles/interaction-particles-attract 4.0.0-alpha.2 → 4.0.0-alpha.21

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/634.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_interaction_particles_attract=this.webpackChunk_tsparticles_interaction_particles_attract||[]).push([[634],{634(t,e,a){a.d(e,{Attractor:()=>c});var i=a(303),r=a(702);class c extends r.ParticlesInteractorBase{constructor(t){super(t)}clear(){}init(){}interact(t){let e=this.container;t.attractDistance??=(0,i.getRangeValue)(t.options.move.attract.distance)*e.retina.pixelRatio;let a=t.attractDistance,r=t.getPosition();for(let c of e.particles.quadTree.queryCircle(r,a)){if(t===c||!c.options.move.attract.enable||c.destroyed||c.spawning)continue;let e=c.getPosition(),{dx:a,dy:s}=(0,i.getDistances)(r,e),n=t.options.move.attract.rotate,o=a/(1e3*n.x),l=s/(1e3*n.y),p=c.size.value/t.size.value,u=1/p;t.velocity.x-=o*p,t.velocity.y-=l*p,c.velocity.x+=o*u,c.velocity.y+=l*u}}isEnabled(t){return t.options.move.attract.enable}reset(){}}}}]);
package/README.md CHANGED
@@ -27,6 +27,7 @@ Once the scripts are loaded you can set up `tsParticles` and the interaction plu
27
27
 
28
28
  ```javascript
29
29
  (async () => {
30
+ await loadInteractivityPlugin(tsParticles);
30
31
  await loadParticlesAttractInteraction(tsParticles);
31
32
 
32
33
  await tsParticles.load({
@@ -56,9 +57,11 @@ Then you need to import it in the app, like this:
56
57
 
57
58
  ```javascript
58
59
  const { tsParticles } = require("@tsparticles/engine");
60
+ const { loadInteractivityPlugin } = require("@tsparticles/plugin-interactivity");
59
61
  const { loadParticlesAttractInteraction } = require("@tsparticles/interaction-particles-attract");
60
62
 
61
63
  (async () => {
64
+ await loadInteractivityPlugin(tsParticles);
62
65
  await loadParticlesAttractInteraction(tsParticles);
63
66
  })();
64
67
  ```
@@ -67,9 +70,11 @@ or
67
70
 
68
71
  ```javascript
69
72
  import { tsParticles } from "@tsparticles/engine";
73
+ import { loadInteractivityPlugin } from "@tsparticles/plugin-interactivity";
70
74
  import { loadParticlesAttractInteraction } from "@tsparticles/interaction-particles-attract";
71
75
 
72
76
  (async () => {
77
+ await loadInteractivityPlugin(tsParticles);
73
78
  await loadParticlesAttractInteraction(tsParticles);
74
79
  })();
75
80
  ```
@@ -1,4 +1,5 @@
1
- import { ParticlesInteractorBase, getDistances, getRangeValue, } from "@tsparticles/engine";
1
+ import { getDistances, getRangeValue } from "@tsparticles/engine";
2
+ import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
2
3
  const attractFactor = 1000, identity = 1;
3
4
  export class Attractor extends ParticlesInteractorBase {
4
5
  constructor(container) {
package/browser/index.js CHANGED
@@ -1,7 +1,9 @@
1
- export function loadParticlesAttractInteraction(engine) {
2
- engine.checkVersion("4.0.0-alpha.2");
3
- engine.register(e => {
4
- e.addInteractor("particlesAttract", async (container) => {
1
+ export async function loadParticlesAttractInteraction(engine) {
2
+ engine.checkVersion("4.0.0-alpha.21");
3
+ await engine.register(async (e) => {
4
+ const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
5
+ ensureInteractivityPluginLoaded(e);
6
+ e.addInteractor?.("particlesAttract", async (container) => {
5
7
  const { Attractor } = await import("./Attractor.js");
6
8
  return new Attractor(container);
7
9
  });
package/cjs/Attractor.js CHANGED
@@ -1,4 +1,5 @@
1
- import { ParticlesInteractorBase, getDistances, getRangeValue, } from "@tsparticles/engine";
1
+ import { getDistances, getRangeValue } from "@tsparticles/engine";
2
+ import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
2
3
  const attractFactor = 1000, identity = 1;
3
4
  export class Attractor extends ParticlesInteractorBase {
4
5
  constructor(container) {
package/cjs/index.js CHANGED
@@ -1,7 +1,9 @@
1
- export function loadParticlesAttractInteraction(engine) {
2
- engine.checkVersion("4.0.0-alpha.2");
3
- engine.register(e => {
4
- e.addInteractor("particlesAttract", async (container) => {
1
+ export async function loadParticlesAttractInteraction(engine) {
2
+ engine.checkVersion("4.0.0-alpha.21");
3
+ await engine.register(async (e) => {
4
+ const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
5
+ ensureInteractivityPluginLoaded(e);
6
+ e.addInteractor?.("particlesAttract", async (container) => {
5
7
  const { Attractor } = await import("./Attractor.js");
6
8
  return new Attractor(container);
7
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-alpha.2
7
+ * v4.0.0-alpha.21
8
8
  */
9
9
  "use strict";
10
10
  /*
@@ -23,7 +23,7 @@
23
23
  \***********************************/
24
24
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25
25
 
26
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Attractor: () => (/* binding */ Attractor)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst attractFactor = 1000,\n identity = 1;\nclass Attractor extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ParticlesInteractorBase {\n constructor(container) {\n super(container);\n }\n clear() {}\n init() {}\n interact(p1) {\n const container = this.container;\n p1.attractDistance ??= (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(p1.options.move.attract.distance) * container.retina.pixelRatio;\n const distance = p1.attractDistance,\n pos1 = p1.getPosition(),\n query = container.particles.quadTree.queryCircle(pos1, distance);\n for (const p2 of query) {\n if (p1 === p2 || !p2.options.move.attract.enable || p2.destroyed || p2.spawning) {\n continue;\n }\n const pos2 = p2.getPosition(),\n {\n dx,\n dy\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(pos1, pos2),\n rotate = p1.options.move.attract.rotate,\n ax = dx / (rotate.x * attractFactor),\n ay = dy / (rotate.y * attractFactor),\n p1Factor = p2.size.value / p1.size.value,\n p2Factor = identity / p1Factor;\n p1.velocity.x -= ax * p1Factor;\n p1.velocity.y -= ay * p1Factor;\n p2.velocity.x += ax * p2Factor;\n p2.velocity.y += ay * p2Factor;\n }\n }\n isEnabled(particle) {\n return particle.options.move.attract.enable;\n }\n reset() {}\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-attract/./dist/browser/Attractor.js?\n}");
26
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Attractor: () => (/* binding */ Attractor)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\");\n\n\nconst attractFactor = 1000, identity = 1;\nclass Attractor extends _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__.ParticlesInteractorBase {\n constructor(container){\n super(container);\n }\n clear() {}\n init() {}\n interact(p1) {\n const container = this.container;\n p1.attractDistance ??= (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(p1.options.move.attract.distance) * container.retina.pixelRatio;\n const distance = p1.attractDistance, pos1 = p1.getPosition(), query = container.particles.quadTree.queryCircle(pos1, distance);\n for (const p2 of query){\n if (p1 === p2 || !p2.options.move.attract.enable || p2.destroyed || p2.spawning) {\n continue;\n }\n const pos2 = p2.getPosition(), { dx, dy } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(pos1, pos2), rotate = p1.options.move.attract.rotate, ax = dx / (rotate.x * attractFactor), ay = dy / (rotate.y * attractFactor), p1Factor = p2.size.value / p1.size.value, p2Factor = identity / p1Factor;\n p1.velocity.x -= ax * p1Factor;\n p1.velocity.y -= ay * p1Factor;\n p2.velocity.x += ax * p2Factor;\n p2.velocity.y += ay * p2Factor;\n }\n }\n isEnabled(particle) {\n return particle.options.move.attract.enable;\n }\n reset() {}\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-attract/./dist/browser/Attractor.js?\n}");
27
27
 
28
28
  /***/ }
29
29
 
package/esm/Attractor.js CHANGED
@@ -1,4 +1,5 @@
1
- import { ParticlesInteractorBase, getDistances, getRangeValue, } from "@tsparticles/engine";
1
+ import { getDistances, getRangeValue } from "@tsparticles/engine";
2
+ import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
2
3
  const attractFactor = 1000, identity = 1;
3
4
  export class Attractor extends ParticlesInteractorBase {
4
5
  constructor(container) {
package/esm/index.js CHANGED
@@ -1,7 +1,9 @@
1
- export function loadParticlesAttractInteraction(engine) {
2
- engine.checkVersion("4.0.0-alpha.2");
3
- engine.register(e => {
4
- e.addInteractor("particlesAttract", async (container) => {
1
+ export async function loadParticlesAttractInteraction(engine) {
2
+ engine.checkVersion("4.0.0-alpha.21");
3
+ await engine.register(async (e) => {
4
+ const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
5
+ ensureInteractivityPluginLoaded(e);
6
+ e.addInteractor?.("particlesAttract", async (container) => {
5
7
  const { Attractor } = await import("./Attractor.js");
6
8
  return new Attractor(container);
7
9
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/interaction-particles-attract",
3
- "version": "4.0.0-alpha.2",
3
+ "version": "4.0.0-alpha.21",
4
4
  "description": "tsParticles attract particles interaction",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -87,7 +87,8 @@
87
87
  "./package.json": "./package.json"
88
88
  },
89
89
  "dependencies": {
90
- "@tsparticles/engine": "4.0.0-alpha.2"
90
+ "@tsparticles/engine": "4.0.0-alpha.21",
91
+ "@tsparticles/plugin-interactivity": "4.0.0-alpha.21"
91
92
  },
92
93
  "publishConfig": {
93
94
  "access": "public"