@tsparticles/interaction-particles-repulse 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
- "loadParticlesRepulseInteraction": () => (/* binding */ loadParticlesRepulseInteraction)
94
+ loadParticlesRepulseInteraction: () => (/* binding */ loadParticlesRepulseInteraction)
95
95
  });
96
96
 
97
97
  // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
@@ -175,23 +175,22 @@ class Repulser extends engine_root_window_.ParticlesInteractorBase {
175
175
  }
176
176
  }
177
177
  isEnabled(particle) {
178
- var _a, _b;
179
- return (_b = (_a = particle.options.repulse) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : false;
178
+ return particle.options.repulse?.enabled ?? false;
180
179
  }
181
180
  loadParticlesOptions(options, ...sources) {
182
181
  if (!options.repulse) {
183
182
  options.repulse = new ParticlesRepulse();
184
183
  }
185
184
  for (const source of sources) {
186
- options.repulse.load(source === null || source === void 0 ? void 0 : source.repulse);
185
+ options.repulse.load(source?.repulse);
187
186
  }
188
187
  }
189
188
  reset() {}
190
189
  }
191
190
  ;// CONCATENATED MODULE: ./dist/browser/index.js
192
191
 
193
- function loadParticlesRepulseInteraction(engine) {
194
- engine.addInteractor("particlesRepulse", container => new Repulser(container));
192
+ async function loadParticlesRepulseInteraction(engine, refresh = true) {
193
+ await engine.addInteractor("particlesRepulse", container => new Repulser(container), refresh);
195
194
  }
196
195
  })();
197
196
 
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.interaction.particles.repulse.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 o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var r in o)("object"==typeof exports?exports:e)[r]=o[r]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},o={};function r(e){var s=o[e];if(void 0!==s)return s.exports;var n=o[e]={exports:{}};return t[e](n,n.exports,r),n.exports}r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return(()=>{r.r(s),r.d(s,{loadParticlesRepulseInteraction:()=>n});var e=r(533);class t extends e.ValueWithRandom{constructor(){super(),this.enabled=!1,this.distance=1,this.duration=1,this.factor=1,this.speed=1}load(t){super.load(t),t&&(void 0!==t.enabled&&(this.enabled=t.enabled),void 0!==t.distance&&(this.distance=(0,e.setRangeValue)(t.distance)),void 0!==t.duration&&(this.duration=(0,e.setRangeValue)(t.duration)),void 0!==t.factor&&(this.factor=(0,e.setRangeValue)(t.factor)),void 0!==t.speed&&(this.speed=(0,e.setRangeValue)(t.speed)))}}class o extends e.ParticlesInteractorBase{constructor(e){super(e)}clear(){}init(){}async interact(t){const o=this.container;if(!t.repulse){const r=t.options.repulse;if(!r)return;t.repulse={distance:(0,e.getRangeValue)(r.distance)*o.retina.pixelRatio,speed:(0,e.getRangeValue)(r.speed),factor:(0,e.getRangeValue)(r.factor)}}const r=t.getPosition(),s=o.particles.quadTree.queryCircle(r,t.repulse.distance);for(const o of s){if(t===o||o.destroyed)continue;const s=o.getPosition(),{dx:n,dy:i,distance:a}=(0,e.getDistances)(s,r),d=t.repulse.speed*t.repulse.factor;if(a>0){const r=(0,e.clamp)((1-Math.pow(a/t.repulse.distance,2))*d,0,d),s=e.Vector.create(n/a*r,i/a*r);o.position.addTo(s)}else{const t=e.Vector.create(d,d);o.position.addTo(t)}}}isEnabled(e){var t,o;return null!==(o=null===(t=e.options.repulse)||void 0===t?void 0:t.enabled)&&void 0!==o&&o}loadParticlesOptions(e,...o){e.repulse||(e.repulse=new t);for(const t of o)e.repulse.load(null==t?void 0:t.repulse)}reset(){}}function n(e){e.addInteractor("particlesRepulse",(e=>new o(e)))}})(),s})()));
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 o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var s in o)("object"==typeof exports?exports:e)[s]=o[s]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},o={};function s(e){var r=o[e];if(void 0!==r)return r.exports;var n=o[e]={exports:{}};return t[e](n,n.exports,s),n.exports}s.d=(e,t)=>{for(var o in t)s.o(t,o)&&!s.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{s.r(r),s.d(r,{loadParticlesRepulseInteraction:()=>n});var e=s(533);class t extends e.ValueWithRandom{constructor(){super(),this.enabled=!1,this.distance=1,this.duration=1,this.factor=1,this.speed=1}load(t){super.load(t),t&&(void 0!==t.enabled&&(this.enabled=t.enabled),void 0!==t.distance&&(this.distance=(0,e.setRangeValue)(t.distance)),void 0!==t.duration&&(this.duration=(0,e.setRangeValue)(t.duration)),void 0!==t.factor&&(this.factor=(0,e.setRangeValue)(t.factor)),void 0!==t.speed&&(this.speed=(0,e.setRangeValue)(t.speed)))}}class o extends e.ParticlesInteractorBase{constructor(e){super(e)}clear(){}init(){}async interact(t){const o=this.container;if(!t.repulse){const s=t.options.repulse;if(!s)return;t.repulse={distance:(0,e.getRangeValue)(s.distance)*o.retina.pixelRatio,speed:(0,e.getRangeValue)(s.speed),factor:(0,e.getRangeValue)(s.factor)}}const s=t.getPosition(),r=o.particles.quadTree.queryCircle(s,t.repulse.distance);for(const o of r){if(t===o||o.destroyed)continue;const r=o.getPosition(),{dx:n,dy:a,distance:i}=(0,e.getDistances)(r,s),c=t.repulse.speed*t.repulse.factor;if(i>0){const s=(0,e.clamp)((1-Math.pow(i/t.repulse.distance,2))*c,0,c),r=e.Vector.create(n/i*s,a/i*s);o.position.addTo(r)}else{const t=e.Vector.create(c,c);o.position.addTo(t)}}}isEnabled(e){return e.options.repulse?.enabled??!1}loadParticlesOptions(e,...o){e.repulse||(e.repulse=new t);for(const t of o)e.repulse.load(t?.repulse)}reset(){}}async function n(e,t=!0){await e.addInteractor("particlesRepulse",(e=>new o(e)),t)}})(),r})()));
@@ -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 Repulse Particles Interaction v3.0.0-beta.0 by Matteo Bruni */
@@ -1,5 +1,4 @@
1
- import type { IOptionLoader, RangeValue, RecursivePartial } from "@tsparticles/engine";
2
- import { ValueWithRandom } from "@tsparticles/engine";
1
+ import { type IOptionLoader, type RangeValue, type RecursivePartial, ValueWithRandom } from "@tsparticles/engine";
3
2
  import type { IParticlesRepulse } from "../Interfaces/IParticlesRepulse";
4
3
  export declare class ParticlesRepulse extends ValueWithRandom implements IParticlesRepulse, IOptionLoader<IParticlesRepulse> {
5
4
  distance: RangeValue;
@@ -1,6 +1,5 @@
1
- import type { Container, Particle, RecursivePartial } from "@tsparticles/engine";
1
+ import { type Container, type Particle, ParticlesInteractorBase, type RecursivePartial } from "@tsparticles/engine";
2
2
  import type { IRepulseParticlesOptions, RepulseParticlesOptions } from "./Types";
3
- import { ParticlesInteractorBase } from "@tsparticles/engine";
4
3
  type RepulseParticle = Particle & {
5
4
  options: RepulseParticlesOptions;
6
5
  repulse?: {
package/types/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import type { Engine } from "@tsparticles/engine";
2
- export declare function loadParticlesRepulseInteraction(engine: Engine): void;
2
+ export declare function loadParticlesRepulseInteraction(engine: Engine, refresh?: boolean): Promise<void>;
package/umd/Repulser.js CHANGED
@@ -53,15 +53,14 @@
53
53
  }
54
54
  }
55
55
  isEnabled(particle) {
56
- var _a, _b;
57
- return (_b = (_a = particle.options.repulse) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : false;
56
+ return particle.options.repulse?.enabled ?? false;
58
57
  }
59
58
  loadParticlesOptions(options, ...sources) {
60
59
  if (!options.repulse) {
61
60
  options.repulse = new ParticlesRepulse_1.ParticlesRepulse();
62
61
  }
63
62
  for (const source of sources) {
64
- options.repulse.load(source === null || source === void 0 ? void 0 : source.repulse);
63
+ options.repulse.load(source?.repulse);
65
64
  }
66
65
  }
67
66
  reset() {
package/umd/index.js CHANGED
@@ -11,8 +11,8 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.loadParticlesRepulseInteraction = void 0;
13
13
  const Repulser_1 = require("./Repulser");
14
- function loadParticlesRepulseInteraction(engine) {
15
- engine.addInteractor("particlesRepulse", (container) => new Repulser_1.Repulser(container));
14
+ async function loadParticlesRepulseInteraction(engine, refresh = true) {
15
+ await engine.addInteractor("particlesRepulse", (container) => new Repulser_1.Repulser(container), refresh);
16
16
  }
17
17
  exports.loadParticlesRepulseInteraction = loadParticlesRepulseInteraction;
18
18
  });