@tsparticles/interaction-particles-repulse 3.9.1 → 4.0.0-alpha.1

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/929.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 929.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_interaction_particles_repulse=this.webpackChunk_tsparticles_interaction_particles_repulse||[]).push([[929],{929(e,t,s){s.d(t,{Repulser:()=>n});var a=s(303);class i extends a.ValueWithRandom{constructor(){super(),this.enabled=!1,this.distance=1,this.duration=1,this.factor=1,this.speed=1}load(e){super.load(e),(0,a.isNull)(e)||(void 0!==e.enabled&&(this.enabled=e.enabled),void 0!==e.distance&&(this.distance=(0,a.setRangeValue)(e.distance)),void 0!==e.duration&&(this.duration=(0,a.setRangeValue)(e.duration)),void 0!==e.factor&&(this.factor=(0,a.setRangeValue)(e.factor)),void 0!==e.speed&&(this.speed=(0,a.setRangeValue)(e.speed)))}}class n extends a.ParticlesInteractorBase{constructor(e){super(e)}clear(){}init(){}interact(e){const t=this.container;if(!e.repulse){const s=e.options.repulse;if(!s)return;e.repulse={distance:(0,a.getRangeValue)(s.distance)*t.retina.pixelRatio,speed:(0,a.getRangeValue)(s.speed),factor:(0,a.getRangeValue)(s.factor)}}const s=e.getPosition(),i=t.particles.quadTree.queryCircle(s,e.repulse.distance);for(const t of i){if(e===t||t.destroyed)continue;const i=t.getPosition(),{dx:n,dy:r,distance:o}=(0,a.getDistances)(i,s),c=e.repulse.speed*e.repulse.factor;if(o>0){const s=(0,a.clamp)((1-Math.pow(o/e.repulse.distance,2))*c,0,c),i=a.Vector.create(n/o*s,r/o*s);t.position.addTo(i)}else{const e=a.Vector.create(c,c);t.position.addTo(e)}}}isEnabled(e){return e.options.repulse?.enabled??!1}loadParticlesOptions(e,...t){e.repulse??=new i;for(const s of t)e.repulse.load(s?.repulse)}reset(){}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Repulse Particles Interaction v4.0.0-alpha.1 by Matteo Bruni */
@@ -42,9 +42,7 @@ export class Repulser extends ParticlesInteractorBase {
42
42
  return particle.options.repulse?.enabled ?? false;
43
43
  }
44
44
  loadParticlesOptions(options, ...sources) {
45
- if (!options.repulse) {
46
- options.repulse = new ParticlesRepulse();
47
- }
45
+ options.repulse ??= new ParticlesRepulse();
48
46
  for (const source of sources) {
49
47
  options.repulse.load(source?.repulse);
50
48
  }
package/browser/index.js CHANGED
@@ -1,7 +1,9 @@
1
- import { Repulser } from "./Repulser.js";
2
- export async function loadParticlesRepulseInteraction(engine, refresh = true) {
3
- engine.checkVersion("3.9.1");
4
- await engine.addInteractor("particlesRepulse", container => {
5
- return Promise.resolve(new Repulser(container));
6
- }, refresh);
1
+ export function loadParticlesRepulseInteraction(engine) {
2
+ engine.checkVersion("4.0.0-alpha.1");
3
+ engine.register(e => {
4
+ e.addInteractor("particlesRepulse", async (container) => {
5
+ const { Repulser } = await import("./Repulser.js");
6
+ return new Repulser(container);
7
+ });
8
+ });
7
9
  }
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParticlesRepulse = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- class ParticlesRepulse extends engine_1.ValueWithRandom {
1
+ import { ValueWithRandom, isNull, setRangeValue, } from "@tsparticles/engine";
2
+ export class ParticlesRepulse extends ValueWithRandom {
6
3
  constructor() {
7
4
  super();
8
5
  this.enabled = false;
@@ -13,24 +10,23 @@ class ParticlesRepulse extends engine_1.ValueWithRandom {
13
10
  }
14
11
  load(data) {
15
12
  super.load(data);
16
- if ((0, engine_1.isNull)(data)) {
13
+ if (isNull(data)) {
17
14
  return;
18
15
  }
19
16
  if (data.enabled !== undefined) {
20
17
  this.enabled = data.enabled;
21
18
  }
22
19
  if (data.distance !== undefined) {
23
- this.distance = (0, engine_1.setRangeValue)(data.distance);
20
+ this.distance = setRangeValue(data.distance);
24
21
  }
25
22
  if (data.duration !== undefined) {
26
- this.duration = (0, engine_1.setRangeValue)(data.duration);
23
+ this.duration = setRangeValue(data.duration);
27
24
  }
28
25
  if (data.factor !== undefined) {
29
- this.factor = (0, engine_1.setRangeValue)(data.factor);
26
+ this.factor = setRangeValue(data.factor);
30
27
  }
31
28
  if (data.speed !== undefined) {
32
- this.speed = (0, engine_1.setRangeValue)(data.speed);
29
+ this.speed = setRangeValue(data.speed);
33
30
  }
34
31
  }
35
32
  }
36
- exports.ParticlesRepulse = ParticlesRepulse;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/cjs/Repulser.js CHANGED
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Repulser = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- const ParticlesRepulse_js_1 = require("./Options/Classes/ParticlesRepulse.js");
1
+ import { ParticlesInteractorBase, Vector, clamp, getDistances, getRangeValue, } from "@tsparticles/engine";
2
+ import { ParticlesRepulse } from "./Options/Classes/ParticlesRepulse.js";
6
3
  const minDistance = 0, identity = 1, squareExp = 2, minVelocity = 0;
7
- class Repulser extends engine_1.ParticlesInteractorBase {
4
+ export class Repulser extends ParticlesInteractorBase {
8
5
  constructor(container) {
9
6
  super(container);
10
7
  }
@@ -20,9 +17,9 @@ class Repulser extends engine_1.ParticlesInteractorBase {
20
17
  return;
21
18
  }
22
19
  p1.repulse = {
23
- distance: (0, engine_1.getRangeValue)(repulseOpt1.distance) * container.retina.pixelRatio,
24
- speed: (0, engine_1.getRangeValue)(repulseOpt1.speed),
25
- factor: (0, engine_1.getRangeValue)(repulseOpt1.factor),
20
+ distance: getRangeValue(repulseOpt1.distance) * container.retina.pixelRatio,
21
+ speed: getRangeValue(repulseOpt1.speed),
22
+ factor: getRangeValue(repulseOpt1.factor),
26
23
  };
27
24
  }
28
25
  const pos1 = p1.getPosition(), query = container.particles.quadTree.queryCircle(pos1, p1.repulse.distance);
@@ -30,13 +27,13 @@ class Repulser extends engine_1.ParticlesInteractorBase {
30
27
  if (p1 === p2 || p2.destroyed) {
31
28
  continue;
32
29
  }
33
- const pos2 = p2.getPosition(), { dx, dy, distance } = (0, engine_1.getDistances)(pos2, pos1), velocity = p1.repulse.speed * p1.repulse.factor;
30
+ const pos2 = p2.getPosition(), { dx, dy, distance } = getDistances(pos2, pos1), velocity = p1.repulse.speed * p1.repulse.factor;
34
31
  if (distance > minDistance) {
35
- const repulseFactor = (0, engine_1.clamp)((identity - Math.pow(distance / p1.repulse.distance, squareExp)) * velocity, minVelocity, velocity), normVec = engine_1.Vector.create((dx / distance) * repulseFactor, (dy / distance) * repulseFactor);
32
+ const repulseFactor = clamp((identity - Math.pow(distance / p1.repulse.distance, squareExp)) * velocity, minVelocity, velocity), normVec = Vector.create((dx / distance) * repulseFactor, (dy / distance) * repulseFactor);
36
33
  p2.position.addTo(normVec);
37
34
  }
38
35
  else {
39
- const velocityVec = engine_1.Vector.create(velocity, velocity);
36
+ const velocityVec = Vector.create(velocity, velocity);
40
37
  p2.position.addTo(velocityVec);
41
38
  }
42
39
  }
@@ -45,9 +42,7 @@ class Repulser extends engine_1.ParticlesInteractorBase {
45
42
  return particle.options.repulse?.enabled ?? false;
46
43
  }
47
44
  loadParticlesOptions(options, ...sources) {
48
- if (!options.repulse) {
49
- options.repulse = new ParticlesRepulse_js_1.ParticlesRepulse();
50
- }
45
+ options.repulse ??= new ParticlesRepulse();
51
46
  for (const source of sources) {
52
47
  options.repulse.load(source?.repulse);
53
48
  }
@@ -55,4 +50,3 @@ class Repulser extends engine_1.ParticlesInteractorBase {
55
50
  reset() {
56
51
  }
57
52
  }
58
- exports.Repulser = Repulser;
package/cjs/Types.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/cjs/index.js CHANGED
@@ -1,10 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadParticlesRepulseInteraction = loadParticlesRepulseInteraction;
4
- const Repulser_js_1 = require("./Repulser.js");
5
- async function loadParticlesRepulseInteraction(engine, refresh = true) {
6
- engine.checkVersion("3.9.1");
7
- await engine.addInteractor("particlesRepulse", container => {
8
- return Promise.resolve(new Repulser_js_1.Repulser(container));
9
- }, refresh);
1
+ export function loadParticlesRepulseInteraction(engine) {
2
+ engine.checkVersion("4.0.0-alpha.1");
3
+ engine.register(e => {
4
+ e.addInteractor("particlesRepulse", async (container) => {
5
+ const { Repulser } = await import("./Repulser.js");
6
+ return new Repulser(container);
7
+ });
8
+ });
10
9
  }
@@ -0,0 +1,40 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v4.0.0-alpha.1
8
+ */
9
+ "use strict";
10
+ /*
11
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
12
+ * This devtool is neither made for production nor for readable output files.
13
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
14
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
15
+ * or disable the default devtool with "devtool: false".
16
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
17
+ */
18
+ (this["webpackChunk_tsparticles_interaction_particles_repulse"] = this["webpackChunk_tsparticles_interaction_particles_repulse"] || []).push([["dist_browser_Repulser_js"],{
19
+
20
+ /***/ "./dist/browser/Options/Classes/ParticlesRepulse.js"
21
+ /*!**********************************************************!*\
22
+ !*** ./dist/browser/Options/Classes/ParticlesRepulse.js ***!
23
+ \**********************************************************/
24
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25
+
26
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ParticlesRepulse: () => (/* binding */ ParticlesRepulse)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass ParticlesRepulse extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ValueWithRandom {\n constructor() {\n super();\n this.enabled = false;\n this.distance = 1;\n this.duration = 1;\n this.factor = 1;\n this.speed = 1;\n }\n load(data) {\n super.load(data);\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.enabled !== undefined) {\n this.enabled = data.enabled;\n }\n if (data.distance !== undefined) {\n this.distance = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.distance);\n }\n if (data.duration !== undefined) {\n this.duration = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.duration);\n }\n if (data.factor !== undefined) {\n this.factor = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.factor);\n }\n if (data.speed !== undefined) {\n this.speed = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.speed);\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-repulse/./dist/browser/Options/Classes/ParticlesRepulse.js?\n}");
27
+
28
+ /***/ },
29
+
30
+ /***/ "./dist/browser/Repulser.js"
31
+ /*!**********************************!*\
32
+ !*** ./dist/browser/Repulser.js ***!
33
+ \**********************************/
34
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
35
+
36
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Repulser: () => (/* binding */ Repulser)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Options_Classes_ParticlesRepulse_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/ParticlesRepulse.js */ \"./dist/browser/Options/Classes/ParticlesRepulse.js\");\n\n\nconst minDistance = 0,\n identity = 1,\n squareExp = 2,\n minVelocity = 0;\nclass Repulser 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 if (!p1.repulse) {\n const repulseOpt1 = p1.options.repulse;\n if (!repulseOpt1) {\n return;\n }\n p1.repulse = {\n distance: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(repulseOpt1.distance) * container.retina.pixelRatio,\n speed: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(repulseOpt1.speed),\n factor: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(repulseOpt1.factor)\n };\n }\n const pos1 = p1.getPosition(),\n query = container.particles.quadTree.queryCircle(pos1, p1.repulse.distance);\n for (const p2 of query) {\n if (p1 === p2 || p2.destroyed) {\n continue;\n }\n const pos2 = p2.getPosition(),\n {\n dx,\n dy,\n distance\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(pos2, pos1),\n velocity = p1.repulse.speed * p1.repulse.factor;\n if (distance > minDistance) {\n const repulseFactor = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.clamp)((identity - Math.pow(distance / p1.repulse.distance, squareExp)) * velocity, minVelocity, velocity),\n normVec = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.create(dx / distance * repulseFactor, dy / distance * repulseFactor);\n p2.position.addTo(normVec);\n } else {\n const velocityVec = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.create(velocity, velocity);\n p2.position.addTo(velocityVec);\n }\n }\n }\n isEnabled(particle) {\n return particle.options.repulse?.enabled ?? false;\n }\n loadParticlesOptions(options, ...sources) {\n options.repulse ??= new _Options_Classes_ParticlesRepulse_js__WEBPACK_IMPORTED_MODULE_1__.ParticlesRepulse();\n for (const source of sources) {\n options.repulse.load(source?.repulse);\n }\n }\n reset() {}\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-repulse/./dist/browser/Repulser.js?\n}");
37
+
38
+ /***/ }
39
+
40
+ }]);
package/esm/Repulser.js CHANGED
@@ -42,9 +42,7 @@ export class Repulser extends ParticlesInteractorBase {
42
42
  return particle.options.repulse?.enabled ?? false;
43
43
  }
44
44
  loadParticlesOptions(options, ...sources) {
45
- if (!options.repulse) {
46
- options.repulse = new ParticlesRepulse();
47
- }
45
+ options.repulse ??= new ParticlesRepulse();
48
46
  for (const source of sources) {
49
47
  options.repulse.load(source?.repulse);
50
48
  }
package/esm/index.js CHANGED
@@ -1,7 +1,9 @@
1
- import { Repulser } from "./Repulser.js";
2
- export async function loadParticlesRepulseInteraction(engine, refresh = true) {
3
- engine.checkVersion("3.9.1");
4
- await engine.addInteractor("particlesRepulse", container => {
5
- return Promise.resolve(new Repulser(container));
6
- }, refresh);
1
+ export function loadParticlesRepulseInteraction(engine) {
2
+ engine.checkVersion("4.0.0-alpha.1");
3
+ engine.register(e => {
4
+ e.addInteractor("particlesRepulse", async (container) => {
5
+ const { Repulser } = await import("./Repulser.js");
6
+ return new Repulser(container);
7
+ });
8
+ });
7
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/interaction-particles-repulse",
3
- "version": "3.9.1",
3
+ "version": "4.0.0-alpha.1",
4
4
  "description": "tsParticles repulse particles interaction",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -101,9 +101,10 @@
101
101
  "./package.json": "./package.json"
102
102
  },
103
103
  "dependencies": {
104
- "@tsparticles/engine": "3.9.1"
104
+ "@tsparticles/engine": "4.0.0-alpha.1"
105
105
  },
106
106
  "publishConfig": {
107
107
  "access": "public"
108
- }
108
+ },
109
+ "type": "module"
109
110
  }