@tsparticles/interaction-particles-attract 3.0.0-alpha.1 → 3.0.0-beta.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.
@@ -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
- * v3.0.0-alpha.1
7
+ * v3.0.0-beta.0
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -91,7 +91,7 @@ __webpack_require__.r(__webpack_exports__);
91
91
 
92
92
  // EXPORTS
93
93
  __webpack_require__.d(__webpack_exports__, {
94
- "loadParticlesAttractInteraction": () => (/* binding */ loadParticlesAttractInteraction)
94
+ loadParticlesAttractInteraction: () => (/* binding */ loadParticlesAttractInteraction)
95
95
  });
96
96
 
97
97
  // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
@@ -105,9 +105,8 @@ class Attractor extends engine_root_window_.ParticlesInteractorBase {
105
105
  clear() {}
106
106
  init() {}
107
107
  async interact(p1) {
108
- var _a;
109
108
  const container = this.container,
110
- distance = (_a = p1.retina.attractDistance) !== null && _a !== void 0 ? _a : container.retina.attractDistance,
109
+ distance = p1.retina.attractDistance ?? container.retina.attractDistance,
111
110
  pos1 = p1.getPosition(),
112
111
  query = container.particles.quadTree.queryCircle(pos1, distance);
113
112
  for (const p2 of query) {
@@ -137,8 +136,8 @@ class Attractor extends engine_root_window_.ParticlesInteractorBase {
137
136
  }
138
137
  ;// CONCATENATED MODULE: ./dist/browser/index.js
139
138
 
140
- async function loadParticlesAttractInteraction(engine) {
141
- await engine.addInteractor("particlesAttract", container => new Attractor(container));
139
+ async function loadParticlesAttractInteraction(engine, refresh = true) {
140
+ await engine.addInteractor("particlesAttract", container => new Attractor(container), refresh);
142
141
  }
143
142
  })();
144
143
 
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.interaction.particles.attract.min.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{loadParticlesAttractInteraction:()=>r});var e=o(533);class t extends e.ParticlesInteractorBase{constructor(e){super(e)}clear(){}init(){}async interact(t){var r;const o=this.container,n=null!==(r=t.retina.attractDistance)&&void 0!==r?r:o.retina.attractDistance,i=t.getPosition(),a=o.particles.quadTree.queryCircle(i,n);for(const r of a){if(t===r||!r.options.move.attract.enable||r.destroyed||r.spawning)continue;const o=r.getPosition(),{dx:n,dy:a}=(0,e.getDistances)(i,o),s=t.options.move.attract.rotate,c=n/(1e3*s.x),l=a/(1e3*s.y),p=r.size.value/t.size.value,d=1/p;t.velocity.x-=c*p,t.velocity.y-=l*p,r.velocity.x+=c*d,r.velocity.y+=l*d}}isEnabled(e){return e.options.move.attract.enable}reset(){}}async function r(e){await e.addInteractor("particlesAttract",(e=>new t(e)))}})(),n})()));
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{loadParticlesAttractInteraction:()=>r});var e=o(533);class t extends e.ParticlesInteractorBase{constructor(e){super(e)}clear(){}init(){}async interact(t){const r=this.container,o=t.retina.attractDistance??r.retina.attractDistance,n=t.getPosition(),i=r.particles.quadTree.queryCircle(n,o);for(const r of i){if(t===r||!r.options.move.attract.enable||r.destroyed||r.spawning)continue;const o=r.getPosition(),{dx:i,dy:a}=(0,e.getDistances)(n,o),s=t.options.move.attract.rotate,c=i/(1e3*s.x),l=a/(1e3*s.y),p=r.size.value/t.size.value,d=1/p;t.velocity.x-=c*p,t.velocity.y-=l*p,r.velocity.x+=c*d,r.velocity.y+=l*d}}isEnabled(e){return e.options.move.attract.enable}reset(){}}async function r(e,r=!0){await e.addInteractor("particlesAttract",(e=>new t(e)),r)}})(),n})()));
@@ -1,8 +1 @@
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
- * v3.0.0-alpha.1
8
- */
1
+ /*! tsParticles Attract Particles Interaction v3.0.0-beta.0 by Matteo Bruni */
@@ -1,5 +1,4 @@
1
- import type { Container, IParticle, Particle } from "@tsparticles/engine";
2
- import { ParticlesInteractorBase } from "@tsparticles/engine";
1
+ import { type Container, type IParticle, type Particle, ParticlesInteractorBase } from "@tsparticles/engine";
3
2
  export declare class Attractor extends ParticlesInteractorBase {
4
3
  constructor(container: Container);
5
4
  clear(): void;
package/types/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import type { Engine } from "@tsparticles/engine";
2
- export declare function loadParticlesAttractInteraction(engine: Engine): Promise<void>;
2
+ export declare function loadParticlesAttractInteraction(engine: Engine, refresh?: boolean): Promise<void>;
package/umd/Attractor.js CHANGED
@@ -20,8 +20,7 @@
20
20
  init() {
21
21
  }
22
22
  async interact(p1) {
23
- var _a;
24
- const container = this.container, distance = (_a = p1.retina.attractDistance) !== null && _a !== void 0 ? _a : container.retina.attractDistance, pos1 = p1.getPosition(), query = container.particles.quadTree.queryCircle(pos1, distance);
23
+ const container = this.container, distance = p1.retina.attractDistance ?? container.retina.attractDistance, pos1 = p1.getPosition(), query = container.particles.quadTree.queryCircle(pos1, distance);
25
24
  for (const p2 of query) {
26
25
  if (p1 === p2 || !p2.options.move.attract.enable || p2.destroyed || p2.spawning) {
27
26
  continue;
package/umd/index.js CHANGED
@@ -11,8 +11,8 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.loadParticlesAttractInteraction = void 0;
13
13
  const Attractor_1 = require("./Attractor");
14
- async function loadParticlesAttractInteraction(engine) {
15
- await engine.addInteractor("particlesAttract", (container) => new Attractor_1.Attractor(container));
14
+ async function loadParticlesAttractInteraction(engine, refresh = true) {
15
+ await engine.addInteractor("particlesAttract", (container) => new Attractor_1.Attractor(container), refresh);
16
16
  }
17
17
  exports.loadParticlesAttractInteraction = loadParticlesAttractInteraction;
18
18
  });