@tsparticles/interaction-external-attract 4.0.0-alpha.8 → 4.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.
- package/141.min.js +1 -0
- package/README.md +5 -0
- package/browser/Attractor.js +8 -0
- package/browser/Options/Classes/Attract.js +6 -0
- package/browser/Utils.js +6 -4
- package/browser/index.js +3 -3
- package/cjs/Attractor.js +8 -0
- package/cjs/Options/Classes/Attract.js +6 -0
- package/cjs/Utils.js +6 -4
- package/cjs/index.js +3 -3
- package/dist_browser_Attractor_js.js +3 -3
- package/esm/Attractor.js +8 -0
- package/esm/Options/Classes/Attract.js +6 -0
- package/esm/Utils.js +6 -4
- package/esm/index.js +3 -3
- package/package.json +3 -3
- package/report.html +1 -1
- package/tsparticles.interaction.external.attract.js +41 -29
- package/tsparticles.interaction.external.attract.min.js +2 -2
- package/types/Attractor.d.ts +2 -0
- package/umd/Attractor.js +8 -0
- package/umd/Options/Classes/Attract.js +6 -0
- package/umd/Utils.js +6 -4
- package/umd/index.js +3 -3
- package/689.min.js +0 -2
- package/689.min.js.LICENSE.txt +0 -1
- package/tsparticles.interaction.external.attract.min.js.LICENSE.txt +0 -1
package/141.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_interaction_external_attract=this.webpackChunk_tsparticles_interaction_external_attract||[]).push([[141],{141(t,e,i){i.d(e,{Attractor:()=>l});var a=i(303),n=i(702);let c=a.Vector.origin;function r(t,e,i,n,r,s){let o=e.actualOptions.interactivity?.modes.attract;if(o)for(let l of e.particles.grid.query(r,s)){let{dx:e,dy:r,distance:s}=(0,a.getDistances)(l.position,i),d=o.speed*o.factor,u=(0,a.clamp)(t.getEasing(o.easing)(a.identity-s/n)*d,1,o.maxSpeed);c.x=s?e/s*u:d,c.y=s?r/s*u:d,l.position.subFrom(c)}}var s=i(216);let o="attract";class l extends n.ExternalInteractorBase{handleClickMode;_engine;_maxDistance;constructor(t,e){super(e),this._engine=t,this._maxDistance=0,e.attract??={particles:[]},this.handleClickMode=(t,i)=>{let n=this.container.actualOptions,c=n.interactivity?.modes.attract;if(c&&t===o){for(let t of(e.attract??={particles:[]},e.attract.clicking=!0,e.attract.count=0,e.attract.particles))this.isEnabled(i,t)&&t.velocity.setTo(t.initialVelocity);e.attract.particles=[],e.attract.finish=!1,setTimeout(()=>{e.destroyed||(e.attract??={particles:[]},e.attract.clicking=!1)},c.duration*a.millisecondsToSeconds)}}}get maxDistance(){return this._maxDistance}clear(){}init(){let t=this.container,e=t.actualOptions.interactivity?.modes.attract;e&&(this._maxDistance=e.distance,t.retina.attractModeDistance=e.distance*t.retina.pixelRatio)}interact(t){let e=this.container.actualOptions,i=t.status===n.mouseMoveEvent,c=e.interactivity?.events;if(!c)return;let{enable:s,mode:l}=c.onHover,{enable:d,mode:u}=c.onClick;if(i&&s&&(0,a.isInArray)(o,l)){var p,h,m;let e,i;p=this._engine,h=this.container,m=e=>this.isEnabled(t,e),e=t.mouse.position,(i=h.retina.attractModeDistance)&&!(i<0)&&e&&r(p,h,e,i,new a.Circle(e.x,e.y,i),t=>m(t))}else d&&(0,a.isInArray)(o,u)&&function(t,e,i,n){e.attract??={particles:[]};let{attract:c}=e;if(c.finish||(c.count??=0,c.count++,c.count===e.particles.count&&(c.finish=!0)),c.clicking){let c=i.mouse.clickPosition,s=e.retina.attractModeDistance;if(!s||s<0||!c)return;r(t,e,c,s,new a.Circle(c.x,c.y,s),t=>n(t))}else!1===c.clicking&&(c.particles=[])}(this._engine,this.container,t,e=>this.isEnabled(t,e))}isEnabled(t,e){let i=this.container.actualOptions,n=t.mouse,c=(e?.interactivity??i.interactivity)?.events;if((!n.position||!c?.onHover.enable)&&(!n.clickPosition||!c?.onClick.enable))return!1;let r=c.onHover.mode,s=c.onClick.mode;return(0,a.isInArray)(o,r)||(0,a.isInArray)(o,s)}loadModeOptions(t,...e){for(let i of(t.attract??=new s.K,e))t.attract.load(i?.attract)}reset(){}}}}]);
|
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@ Once the scripts are loaded you can set up `tsParticles` and the interaction plu
|
|
|
28
28
|
|
|
29
29
|
```javascript
|
|
30
30
|
(async () => {
|
|
31
|
+
await loadInteractivityPlugin(tsParticles);
|
|
31
32
|
await loadExternalAttractInteraction(tsParticles);
|
|
32
33
|
|
|
33
34
|
await tsParticles.load({
|
|
@@ -57,9 +58,11 @@ Then you need to import it in the app, like this:
|
|
|
57
58
|
|
|
58
59
|
```javascript
|
|
59
60
|
const { tsParticles } = require("@tsparticles/engine");
|
|
61
|
+
const { loadInteractivityPlugin } = require("@tsparticles/plugin-interactivity");
|
|
60
62
|
const { loadExternalAttractInteraction } = require("@tsparticles/interaction-external-attract");
|
|
61
63
|
|
|
62
64
|
(async () => {
|
|
65
|
+
await loadInteractivityPlugin(tsParticles);
|
|
63
66
|
await loadExternalAttractInteraction(tsParticles);
|
|
64
67
|
})();
|
|
65
68
|
```
|
|
@@ -68,9 +71,11 @@ or
|
|
|
68
71
|
|
|
69
72
|
```javascript
|
|
70
73
|
import { tsParticles } from "@tsparticles/engine";
|
|
74
|
+
import { loadInteractivityPlugin } from "@tsparticles/plugin-interactivity";
|
|
71
75
|
import { loadExternalAttractInteraction } from "@tsparticles/interaction-external-attract";
|
|
72
76
|
|
|
73
77
|
(async () => {
|
|
78
|
+
await loadInteractivityPlugin(tsParticles);
|
|
74
79
|
await loadExternalAttractInteraction(tsParticles);
|
|
75
80
|
})();
|
|
76
81
|
```
|
package/browser/Attractor.js
CHANGED
|
@@ -4,9 +4,13 @@ import { clickAttract, hoverAttract } from "./Utils.js";
|
|
|
4
4
|
import { Attract } from "./Options/Classes/Attract.js";
|
|
5
5
|
const attractMode = "attract";
|
|
6
6
|
export class Attractor extends ExternalInteractorBase {
|
|
7
|
+
handleClickMode;
|
|
8
|
+
_engine;
|
|
9
|
+
_maxDistance;
|
|
7
10
|
constructor(engine, container) {
|
|
8
11
|
super(container);
|
|
9
12
|
this._engine = engine;
|
|
13
|
+
this._maxDistance = 0;
|
|
10
14
|
container.attract ??= { particles: [] };
|
|
11
15
|
this.handleClickMode = (mode, interactivityData) => {
|
|
12
16
|
const options = this.container.actualOptions, attract = options.interactivity?.modes.attract;
|
|
@@ -33,6 +37,9 @@ export class Attractor extends ExternalInteractorBase {
|
|
|
33
37
|
}, attract.duration * millisecondsToSeconds);
|
|
34
38
|
};
|
|
35
39
|
}
|
|
40
|
+
get maxDistance() {
|
|
41
|
+
return this._maxDistance;
|
|
42
|
+
}
|
|
36
43
|
clear() {
|
|
37
44
|
}
|
|
38
45
|
init() {
|
|
@@ -40,6 +47,7 @@ export class Attractor extends ExternalInteractorBase {
|
|
|
40
47
|
if (!attract) {
|
|
41
48
|
return;
|
|
42
49
|
}
|
|
50
|
+
this._maxDistance = attract.distance;
|
|
43
51
|
container.retina.attractModeDistance = attract.distance * container.retina.pixelRatio;
|
|
44
52
|
}
|
|
45
53
|
interact(interactivityData) {
|
package/browser/Utils.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { Circle, Vector, clamp, getDistances, identity, } from "@tsparticles/engine";
|
|
2
|
-
const minFactor = 1, minRadius = 0;
|
|
2
|
+
const minFactor = 1, minRadius = 0, updateVector = Vector.origin;
|
|
3
3
|
function processAttract(engine, container, position, attractRadius, area, queryCb) {
|
|
4
4
|
const attractOptions = container.actualOptions.interactivity?.modes.attract;
|
|
5
5
|
if (!attractOptions) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
|
-
const query = container.particles.
|
|
8
|
+
const query = container.particles.grid.query(area, queryCb);
|
|
9
9
|
for (const particle of query) {
|
|
10
|
-
const { dx, dy, distance } = getDistances(particle.position, position), velocity = attractOptions.speed * attractOptions.factor, attractFactor = clamp(engine.getEasing(attractOptions.easing)(identity - distance / attractRadius) * velocity, minFactor, attractOptions.maxSpeed)
|
|
11
|
-
|
|
10
|
+
const { dx, dy, distance } = getDistances(particle.position, position), velocity = attractOptions.speed * attractOptions.factor, attractFactor = clamp(engine.getEasing(attractOptions.easing)(identity - distance / attractRadius) * velocity, minFactor, attractOptions.maxSpeed);
|
|
11
|
+
updateVector.x = !distance ? velocity : (dx / distance) * attractFactor;
|
|
12
|
+
updateVector.y = !distance ? velocity : (dy / distance) * attractFactor;
|
|
13
|
+
particle.position.subFrom(updateVector);
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
16
|
export function clickAttract(engine, container, interactivityData, enabledCb) {
|
package/browser/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export async function loadExternalAttractInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
2
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
3
3
|
await engine.register(async (e) => {
|
|
4
|
-
const {
|
|
5
|
-
|
|
4
|
+
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
ensureInteractivityPluginLoaded(e);
|
|
6
6
|
e.addInteractor?.("externalAttract", async (container) => {
|
|
7
7
|
const { Attractor } = await import("./Attractor.js");
|
|
8
8
|
return new Attractor(e, container);
|
package/cjs/Attractor.js
CHANGED
|
@@ -4,9 +4,13 @@ import { clickAttract, hoverAttract } from "./Utils.js";
|
|
|
4
4
|
import { Attract } from "./Options/Classes/Attract.js";
|
|
5
5
|
const attractMode = "attract";
|
|
6
6
|
export class Attractor extends ExternalInteractorBase {
|
|
7
|
+
handleClickMode;
|
|
8
|
+
_engine;
|
|
9
|
+
_maxDistance;
|
|
7
10
|
constructor(engine, container) {
|
|
8
11
|
super(container);
|
|
9
12
|
this._engine = engine;
|
|
13
|
+
this._maxDistance = 0;
|
|
10
14
|
container.attract ??= { particles: [] };
|
|
11
15
|
this.handleClickMode = (mode, interactivityData) => {
|
|
12
16
|
const options = this.container.actualOptions, attract = options.interactivity?.modes.attract;
|
|
@@ -33,6 +37,9 @@ export class Attractor extends ExternalInteractorBase {
|
|
|
33
37
|
}, attract.duration * millisecondsToSeconds);
|
|
34
38
|
};
|
|
35
39
|
}
|
|
40
|
+
get maxDistance() {
|
|
41
|
+
return this._maxDistance;
|
|
42
|
+
}
|
|
36
43
|
clear() {
|
|
37
44
|
}
|
|
38
45
|
init() {
|
|
@@ -40,6 +47,7 @@ export class Attractor extends ExternalInteractorBase {
|
|
|
40
47
|
if (!attract) {
|
|
41
48
|
return;
|
|
42
49
|
}
|
|
50
|
+
this._maxDistance = attract.distance;
|
|
43
51
|
container.retina.attractModeDistance = attract.distance * container.retina.pixelRatio;
|
|
44
52
|
}
|
|
45
53
|
interact(interactivityData) {
|
package/cjs/Utils.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { Circle, Vector, clamp, getDistances, identity, } from "@tsparticles/engine";
|
|
2
|
-
const minFactor = 1, minRadius = 0;
|
|
2
|
+
const minFactor = 1, minRadius = 0, updateVector = Vector.origin;
|
|
3
3
|
function processAttract(engine, container, position, attractRadius, area, queryCb) {
|
|
4
4
|
const attractOptions = container.actualOptions.interactivity?.modes.attract;
|
|
5
5
|
if (!attractOptions) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
|
-
const query = container.particles.
|
|
8
|
+
const query = container.particles.grid.query(area, queryCb);
|
|
9
9
|
for (const particle of query) {
|
|
10
|
-
const { dx, dy, distance } = getDistances(particle.position, position), velocity = attractOptions.speed * attractOptions.factor, attractFactor = clamp(engine.getEasing(attractOptions.easing)(identity - distance / attractRadius) * velocity, minFactor, attractOptions.maxSpeed)
|
|
11
|
-
|
|
10
|
+
const { dx, dy, distance } = getDistances(particle.position, position), velocity = attractOptions.speed * attractOptions.factor, attractFactor = clamp(engine.getEasing(attractOptions.easing)(identity - distance / attractRadius) * velocity, minFactor, attractOptions.maxSpeed);
|
|
11
|
+
updateVector.x = !distance ? velocity : (dx / distance) * attractFactor;
|
|
12
|
+
updateVector.y = !distance ? velocity : (dy / distance) * attractFactor;
|
|
13
|
+
particle.position.subFrom(updateVector);
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
16
|
export function clickAttract(engine, container, interactivityData, enabledCb) {
|
package/cjs/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export async function loadExternalAttractInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
2
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
3
3
|
await engine.register(async (e) => {
|
|
4
|
-
const {
|
|
5
|
-
|
|
4
|
+
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
ensureInteractivityPluginLoaded(e);
|
|
6
6
|
e.addInteractor?.("externalAttract", async (container) => {
|
|
7
7
|
const { Attractor } = await import("./Attractor.js");
|
|
8
8
|
return new Attractor(e, container);
|
|
@@ -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-
|
|
7
|
+
* v4.0.0-beta.0
|
|
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/* harmony import */ var _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n/* harmony import */ var _Options_Classes_Attract_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Options/Classes/Attract.js */ \"./dist/browser/Options/Classes/Attract.js\");\n\n\n\n\nconst attractMode = \"attract\";\nclass Attractor extends _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__.ExternalInteractorBase {\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/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n/* harmony import */ var _Options_Classes_Attract_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Options/Classes/Attract.js */ \"./dist/browser/Options/Classes/Attract.js\");\n\n\n\n\nconst attractMode = \"attract\";\nclass Attractor extends _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__.ExternalInteractorBase {\n handleClickMode;\n _engine;\n _maxDistance;\n constructor(engine, container){\n super(container);\n this._engine = engine;\n this._maxDistance = 0;\n container.attract ??= {\n particles: []\n };\n this.handleClickMode = (mode, interactivityData)=>{\n const options = this.container.actualOptions, attract = options.interactivity?.modes.attract;\n if (!attract || mode !== attractMode) {\n return;\n }\n container.attract ??= {\n particles: []\n };\n container.attract.clicking = true;\n container.attract.count = 0;\n for (const particle of container.attract.particles){\n if (!this.isEnabled(interactivityData, particle)) {\n continue;\n }\n particle.velocity.setTo(particle.initialVelocity);\n }\n container.attract.particles = [];\n container.attract.finish = false;\n setTimeout(()=>{\n if (container.destroyed) {\n return;\n }\n container.attract ??= {\n particles: []\n };\n container.attract.clicking = false;\n }, attract.duration * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.millisecondsToSeconds);\n };\n }\n get maxDistance() {\n return this._maxDistance;\n }\n clear() {}\n init() {\n const container = this.container, attract = container.actualOptions.interactivity?.modes.attract;\n if (!attract) {\n return;\n }\n this._maxDistance = attract.distance;\n container.retina.attractModeDistance = attract.distance * container.retina.pixelRatio;\n }\n interact(interactivityData) {\n const container = this.container, options = container.actualOptions, mouseMoveStatus = interactivityData.status === _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__.mouseMoveEvent, events = options.interactivity?.events;\n if (!events) {\n return;\n }\n const { enable: hoverEnabled, mode: hoverMode } = events.onHover, { enable: clickEnabled, mode: clickMode } = events.onClick;\n if (mouseMoveStatus && hoverEnabled && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(attractMode, hoverMode)) {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_2__.hoverAttract)(this._engine, this.container, interactivityData, (p)=>this.isEnabled(interactivityData, p));\n } else if (clickEnabled && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(attractMode, clickMode)) {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_2__.clickAttract)(this._engine, this.container, interactivityData, (p)=>this.isEnabled(interactivityData, p));\n }\n }\n isEnabled(interactivityData, particle) {\n const container = this.container, options = container.actualOptions, mouse = interactivityData.mouse, events = (particle?.interactivity ?? options.interactivity)?.events;\n if ((!mouse.position || !events?.onHover.enable) && (!mouse.clickPosition || !events?.onClick.enable)) {\n return false;\n }\n const hoverMode = events.onHover.mode, clickMode = events.onClick.mode;\n return (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(attractMode, hoverMode) || (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(attractMode, clickMode);\n }\n loadModeOptions(options, ...sources) {\n options.attract ??= new _Options_Classes_Attract_js__WEBPACK_IMPORTED_MODULE_3__.Attract();\n for (const source of sources){\n options.attract.load(source?.attract);\n }\n }\n reset() {}\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-external-attract/./dist/browser/Attractor.js?\n}");
|
|
27
27
|
|
|
28
28
|
/***/ },
|
|
29
29
|
|
|
@@ -33,7 +33,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
33
33
|
\*******************************/
|
|
34
34
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
35
|
|
|
36
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clickAttract: () => (/* binding */ clickAttract),\n/* harmony export */ hoverAttract: () => (/* binding */ hoverAttract)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst minFactor = 1
|
|
36
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ clickAttract: () => (/* binding */ clickAttract),\n/* harmony export */ hoverAttract: () => (/* binding */ hoverAttract)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst minFactor = 1, minRadius = 0, updateVector = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\nfunction processAttract(engine, container, position, attractRadius, area, queryCb) {\n const attractOptions = container.actualOptions.interactivity?.modes.attract;\n if (!attractOptions) {\n return;\n }\n const query = container.particles.grid.query(area, queryCb);\n for (const particle of query){\n const { dx, dy, distance } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(particle.position, position), velocity = attractOptions.speed * attractOptions.factor, attractFactor = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.clamp)(engine.getEasing(attractOptions.easing)(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.identity - distance / attractRadius) * velocity, minFactor, attractOptions.maxSpeed);\n updateVector.x = !distance ? velocity : dx / distance * attractFactor;\n updateVector.y = !distance ? velocity : dy / distance * attractFactor;\n particle.position.subFrom(updateVector);\n }\n}\nfunction clickAttract(engine, container, interactivityData, enabledCb) {\n container.attract ??= {\n particles: []\n };\n const { attract } = container;\n if (!attract.finish) {\n attract.count ??= 0;\n attract.count++;\n if (attract.count === container.particles.count) {\n attract.finish = true;\n }\n }\n if (attract.clicking) {\n const mousePos = interactivityData.mouse.clickPosition, attractRadius = container.retina.attractModeDistance;\n if (!attractRadius || attractRadius < minRadius || !mousePos) {\n return;\n }\n processAttract(engine, container, mousePos, attractRadius, new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Circle(mousePos.x, mousePos.y, attractRadius), (p)=>enabledCb(p));\n } else if (attract.clicking === false) {\n attract.particles = [];\n }\n}\nfunction hoverAttract(engine, container, interactivityData, enabledCb) {\n const mousePos = interactivityData.mouse.position, attractRadius = container.retina.attractModeDistance;\n if (!attractRadius || attractRadius < minRadius || !mousePos) {\n return;\n }\n processAttract(engine, container, mousePos, attractRadius, new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Circle(mousePos.x, mousePos.y, attractRadius), (p)=>enabledCb(p));\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-external-attract/./dist/browser/Utils.js?\n}");
|
|
37
37
|
|
|
38
38
|
/***/ }
|
|
39
39
|
|
package/esm/Attractor.js
CHANGED
|
@@ -4,9 +4,13 @@ import { clickAttract, hoverAttract } from "./Utils.js";
|
|
|
4
4
|
import { Attract } from "./Options/Classes/Attract.js";
|
|
5
5
|
const attractMode = "attract";
|
|
6
6
|
export class Attractor extends ExternalInteractorBase {
|
|
7
|
+
handleClickMode;
|
|
8
|
+
_engine;
|
|
9
|
+
_maxDistance;
|
|
7
10
|
constructor(engine, container) {
|
|
8
11
|
super(container);
|
|
9
12
|
this._engine = engine;
|
|
13
|
+
this._maxDistance = 0;
|
|
10
14
|
container.attract ??= { particles: [] };
|
|
11
15
|
this.handleClickMode = (mode, interactivityData) => {
|
|
12
16
|
const options = this.container.actualOptions, attract = options.interactivity?.modes.attract;
|
|
@@ -33,6 +37,9 @@ export class Attractor extends ExternalInteractorBase {
|
|
|
33
37
|
}, attract.duration * millisecondsToSeconds);
|
|
34
38
|
};
|
|
35
39
|
}
|
|
40
|
+
get maxDistance() {
|
|
41
|
+
return this._maxDistance;
|
|
42
|
+
}
|
|
36
43
|
clear() {
|
|
37
44
|
}
|
|
38
45
|
init() {
|
|
@@ -40,6 +47,7 @@ export class Attractor extends ExternalInteractorBase {
|
|
|
40
47
|
if (!attract) {
|
|
41
48
|
return;
|
|
42
49
|
}
|
|
50
|
+
this._maxDistance = attract.distance;
|
|
43
51
|
container.retina.attractModeDistance = attract.distance * container.retina.pixelRatio;
|
|
44
52
|
}
|
|
45
53
|
interact(interactivityData) {
|
package/esm/Utils.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { Circle, Vector, clamp, getDistances, identity, } from "@tsparticles/engine";
|
|
2
|
-
const minFactor = 1, minRadius = 0;
|
|
2
|
+
const minFactor = 1, minRadius = 0, updateVector = Vector.origin;
|
|
3
3
|
function processAttract(engine, container, position, attractRadius, area, queryCb) {
|
|
4
4
|
const attractOptions = container.actualOptions.interactivity?.modes.attract;
|
|
5
5
|
if (!attractOptions) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
|
-
const query = container.particles.
|
|
8
|
+
const query = container.particles.grid.query(area, queryCb);
|
|
9
9
|
for (const particle of query) {
|
|
10
|
-
const { dx, dy, distance } = getDistances(particle.position, position), velocity = attractOptions.speed * attractOptions.factor, attractFactor = clamp(engine.getEasing(attractOptions.easing)(identity - distance / attractRadius) * velocity, minFactor, attractOptions.maxSpeed)
|
|
11
|
-
|
|
10
|
+
const { dx, dy, distance } = getDistances(particle.position, position), velocity = attractOptions.speed * attractOptions.factor, attractFactor = clamp(engine.getEasing(attractOptions.easing)(identity - distance / attractRadius) * velocity, minFactor, attractOptions.maxSpeed);
|
|
11
|
+
updateVector.x = !distance ? velocity : (dx / distance) * attractFactor;
|
|
12
|
+
updateVector.y = !distance ? velocity : (dy / distance) * attractFactor;
|
|
13
|
+
particle.position.subFrom(updateVector);
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
16
|
export function clickAttract(engine, container, interactivityData, enabledCb) {
|
package/esm/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export async function loadExternalAttractInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
2
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
3
3
|
await engine.register(async (e) => {
|
|
4
|
-
const {
|
|
5
|
-
|
|
4
|
+
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
ensureInteractivityPluginLoaded(e);
|
|
6
6
|
e.addInteractor?.("externalAttract", async (container) => {
|
|
7
7
|
const { Attractor } = await import("./Attractor.js");
|
|
8
8
|
return new Attractor(e, container);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-external-attract",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
4
|
"description": "tsParticles attract external interaction",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
"./package.json": "./package.json"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@tsparticles/engine": "4.0.0-
|
|
91
|
-
"@tsparticles/plugin-interactivity": "4.0.0-
|
|
90
|
+
"@tsparticles/engine": "4.0.0-beta.0",
|
|
91
|
+
"@tsparticles/plugin-interactivity": "4.0.0-beta.0"
|
|
92
92
|
},
|
|
93
93
|
"publishConfig": {
|
|
94
94
|
"access": "public"
|
package/report.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8"/>
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
6
|
-
<title>@tsparticles/interaction-external-attract [
|
|
6
|
+
<title>@tsparticles/interaction-external-attract [19 Mar 2026 at 13:59]</title>
|
|
7
7
|
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
|
|
8
8
|
|
|
9
9
|
<script>
|
|
@@ -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-
|
|
7
|
+
* v4.0.0-beta.0
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -28,26 +28,6 @@ return /******/ (() => { // webpackBootstrap
|
|
|
28
28
|
/******/ "use strict";
|
|
29
29
|
/******/ var __webpack_modules__ = ({
|
|
30
30
|
|
|
31
|
-
/***/ "./dist/browser/Options/Classes/Attract.js"
|
|
32
|
-
/*!*************************************************!*\
|
|
33
|
-
!*** ./dist/browser/Options/Classes/Attract.js ***!
|
|
34
|
-
\*************************************************/
|
|
35
|
-
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
36
|
-
|
|
37
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Attract: () => (/* binding */ Attract)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass Attract {\n constructor() {\n this.distance = 200;\n this.duration = 0.4;\n this.easing = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.EasingType.easeOutQuad;\n this.factor = 1;\n this.maxSpeed = 50;\n this.speed = 1;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.distance !== undefined) {\n this.distance = data.distance;\n }\n if (data.duration !== undefined) {\n this.duration = data.duration;\n }\n if (data.easing !== undefined) {\n this.easing = data.easing;\n }\n if (data.factor !== undefined) {\n this.factor = data.factor;\n }\n if (data.maxSpeed !== undefined) {\n this.maxSpeed = data.maxSpeed;\n }\n if (data.speed !== undefined) {\n this.speed = data.speed;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-external-attract/./dist/browser/Options/Classes/Attract.js?\n}");
|
|
38
|
-
|
|
39
|
-
/***/ },
|
|
40
|
-
|
|
41
|
-
/***/ "./dist/browser/index.js"
|
|
42
|
-
/*!*******************************!*\
|
|
43
|
-
!*** ./dist/browser/index.js ***!
|
|
44
|
-
\*******************************/
|
|
45
|
-
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
46
|
-
|
|
47
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Attract: () => (/* reexport safe */ _Options_Classes_Attract_js__WEBPACK_IMPORTED_MODULE_0__.Attract),\n/* harmony export */ loadExternalAttractInteraction: () => (/* binding */ loadExternalAttractInteraction)\n/* harmony export */ });\n/* harmony import */ var _Options_Classes_Attract_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Options/Classes/Attract.js */ \"./dist/browser/Options/Classes/Attract.js\");\nasync function loadExternalAttractInteraction(engine) {\n engine.checkVersion(\"4.0.0-alpha.8\");\n await engine.register(async e => {\n const {\n loadInteractivityPlugin\n } = await Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\", 19));\n await loadInteractivityPlugin(e);\n e.addInteractor?.(\"externalAttract\", async container => {\n const {\n Attractor\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_Attractor_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./Attractor.js */ \"./dist/browser/Attractor.js\"));\n return new Attractor(e, container);\n });\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-external-attract/./dist/browser/index.js?\n}");
|
|
48
|
-
|
|
49
|
-
/***/ },
|
|
50
|
-
|
|
51
31
|
/***/ "@tsparticles/engine"
|
|
52
32
|
/*!*********************************************************************************************************************************!*\
|
|
53
33
|
!*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
|
|
@@ -66,6 +46,26 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
66
46
|
|
|
67
47
|
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__;
|
|
68
48
|
|
|
49
|
+
/***/ },
|
|
50
|
+
|
|
51
|
+
/***/ "./dist/browser/Options/Classes/Attract.js"
|
|
52
|
+
/*!*************************************************!*\
|
|
53
|
+
!*** ./dist/browser/Options/Classes/Attract.js ***!
|
|
54
|
+
\*************************************************/
|
|
55
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
56
|
+
|
|
57
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Attract: () => (/* binding */ Attract)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass Attract {\n distance;\n duration;\n easing;\n factor;\n maxSpeed;\n speed;\n constructor(){\n this.distance = 200;\n this.duration = 0.4;\n this.easing = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.EasingType.easeOutQuad;\n this.factor = 1;\n this.maxSpeed = 50;\n this.speed = 1;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.distance !== undefined) {\n this.distance = data.distance;\n }\n if (data.duration !== undefined) {\n this.duration = data.duration;\n }\n if (data.easing !== undefined) {\n this.easing = data.easing;\n }\n if (data.factor !== undefined) {\n this.factor = data.factor;\n }\n if (data.maxSpeed !== undefined) {\n this.maxSpeed = data.maxSpeed;\n }\n if (data.speed !== undefined) {\n this.speed = data.speed;\n }\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-external-attract/./dist/browser/Options/Classes/Attract.js?\n}");
|
|
58
|
+
|
|
59
|
+
/***/ },
|
|
60
|
+
|
|
61
|
+
/***/ "./dist/browser/index.js"
|
|
62
|
+
/*!*******************************!*\
|
|
63
|
+
!*** ./dist/browser/index.js ***!
|
|
64
|
+
\*******************************/
|
|
65
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
66
|
+
|
|
67
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Attract: () => (/* reexport safe */ _Options_Classes_Attract_js__WEBPACK_IMPORTED_MODULE_0__.Attract),\n/* harmony export */ loadExternalAttractInteraction: () => (/* binding */ loadExternalAttractInteraction)\n/* harmony export */ });\n/* harmony import */ var _Options_Classes_Attract_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Options/Classes/Attract.js */ \"./dist/browser/Options/Classes/Attract.js\");\nasync function loadExternalAttractInteraction(engine) {\n engine.checkVersion(\"4.0.0-beta.0\");\n await engine.register(async (e)=>{\n const { ensureInteractivityPluginLoaded } = await Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\", 19));\n ensureInteractivityPluginLoaded(e);\n e.addInteractor?.(\"externalAttract\", async (container)=>{\n const { Attractor } = await __webpack_require__.e(/*! import() */ \"dist_browser_Attractor_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./Attractor.js */ \"./dist/browser/Attractor.js\"));\n return new Attractor(e, container);\n });\n });\n}\n\n\n\n//# sourceURL=webpack://@tsparticles/interaction-external-attract/./dist/browser/index.js?\n}");
|
|
68
|
+
|
|
69
69
|
/***/ }
|
|
70
70
|
|
|
71
71
|
/******/ });
|
|
@@ -80,12 +80,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__;
|
|
|
80
80
|
/******/ if (cachedModule !== undefined) {
|
|
81
81
|
/******/ return cachedModule.exports;
|
|
82
82
|
/******/ }
|
|
83
|
-
/******/ // Check if module exists (development only)
|
|
84
|
-
/******/ if (__webpack_modules__[moduleId] === undefined) {
|
|
85
|
-
/******/ var e = new Error("Cannot find module '" + moduleId + "'");
|
|
86
|
-
/******/ e.code = 'MODULE_NOT_FOUND';
|
|
87
|
-
/******/ throw e;
|
|
88
|
-
/******/ }
|
|
89
83
|
/******/ // Create a new module (and put it into the cache)
|
|
90
84
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
91
85
|
/******/ // no module.id needed
|
|
@@ -94,6 +88,12 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__;
|
|
|
94
88
|
/******/ };
|
|
95
89
|
/******/
|
|
96
90
|
/******/ // Execute the module function
|
|
91
|
+
/******/ if (!(moduleId in __webpack_modules__)) {
|
|
92
|
+
/******/ delete __webpack_module_cache__[moduleId];
|
|
93
|
+
/******/ var e = new Error("Cannot find module '" + moduleId + "'");
|
|
94
|
+
/******/ e.code = 'MODULE_NOT_FOUND';
|
|
95
|
+
/******/ throw e;
|
|
96
|
+
/******/ }
|
|
97
97
|
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
98
98
|
/******/
|
|
99
99
|
/******/ // Return the exports of the module
|
|
@@ -168,6 +168,18 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__;
|
|
|
168
168
|
/******/ };
|
|
169
169
|
/******/ })();
|
|
170
170
|
/******/
|
|
171
|
+
/******/ /* webpack/runtime/global */
|
|
172
|
+
/******/ (() => {
|
|
173
|
+
/******/ __webpack_require__.g = (function() {
|
|
174
|
+
/******/ if (typeof globalThis === 'object') return globalThis;
|
|
175
|
+
/******/ try {
|
|
176
|
+
/******/ return this || new Function('return this')();
|
|
177
|
+
/******/ } catch (e) {
|
|
178
|
+
/******/ if (typeof window === 'object') return window;
|
|
179
|
+
/******/ }
|
|
180
|
+
/******/ })();
|
|
181
|
+
/******/ })();
|
|
182
|
+
/******/
|
|
171
183
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
172
184
|
/******/ (() => {
|
|
173
185
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
@@ -232,8 +244,8 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__;
|
|
|
232
244
|
/******/ /* webpack/runtime/publicPath */
|
|
233
245
|
/******/ (() => {
|
|
234
246
|
/******/ var scriptUrl;
|
|
235
|
-
/******/ if (
|
|
236
|
-
/******/ var document =
|
|
247
|
+
/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
|
|
248
|
+
/******/ var document = __webpack_require__.g.document;
|
|
237
249
|
/******/ if (!scriptUrl && document) {
|
|
238
250
|
/******/ if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
|
|
239
251
|
/******/ scriptUrl = document.currentScript.src;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"),require("@tsparticles/plugin-interactivity"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine","@tsparticles/plugin-interactivity"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine"),require("@tsparticles/plugin-interactivity")):t(e.window,e.window);for(var i in r)("object"==typeof exports?exports:e)[i]=r[i]}}(this,(e,t)=>(()=>{"use strict";var r,i,o,a={303(t){t.exports=e},702(e){e.exports=t},216(e,t,r){r.d(t,{K:()=>o});var i=r(303);class o{distance;duration;easing;factor;maxSpeed;speed;constructor(){this.distance=200,this.duration=.4,this.easing=i.EasingType.easeOutQuad,this.factor=1,this.maxSpeed=50,this.speed=1}load(e){(0,i.isNull)(e)||(void 0!==e.distance&&(this.distance=e.distance),void 0!==e.duration&&(this.duration=e.duration),void 0!==e.easing&&(this.easing=e.easing),void 0!==e.factor&&(this.factor=e.factor),void 0!==e.maxSpeed&&(this.maxSpeed=e.maxSpeed),void 0!==e.speed&&(this.speed=e.speed))}}}},n={};function s(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return a[e](r,r.exports,s),r.exports}s.m=a,p=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,s.t=function(e,t){if(1&t&&(e=this(e)),8&t||"object"==typeof e&&e&&(4&t&&e.__esModule||16&t&&"function"==typeof e.then))return e;var r=Object.create(null);s.r(r);var i={};c=c||[null,p({}),p([]),p(p)];for(var o=2&t&&e;("object"==typeof o||"function"==typeof o)&&!~c.indexOf(o);o=p(o))Object.getOwnPropertyNames(o).forEach(t=>i[t]=()=>e[t]);return i.default=()=>e,s.d(r,i),r},s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce((t,r)=>(s.f[r](e,t),t),[])),s.u=e=>""+e+".min.js",s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l={},s.l=(e,t,r,i)=>{if(l[e])return void l[e].push(t);if(void 0!==r)for(var o,a,n=document.getElementsByTagName("script"),c=0;c<n.length;c++){var p=n[c];if(p.getAttribute("src")==e||p.getAttribute("data-webpack")=="@tsparticles/interaction-external-attract:"+r){o=p;break}}o||(a=!0,(o=document.createElement("script")).charset="utf-8",s.nc&&o.setAttribute("nonce",s.nc),o.setAttribute("data-webpack","@tsparticles/interaction-external-attract:"+r),o.src=e),l[e]=[t];var d=(t,r)=>{o.onerror=o.onload=null,clearTimeout(u);var i=l[e];if(delete l[e],o.parentNode&&o.parentNode.removeChild(o),i&&i.forEach(e=>e(r)),t)return t(r)},u=setTimeout(d.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=d.bind(null,o.onerror),o.onload=d.bind(null,o.onload),a&&document.head.appendChild(o)},s.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.g.importScripts&&(d=s.g.location+"");var c,p,l,d,u=s.g.document;if(!d&&u&&(u.currentScript&&"SCRIPT"===u.currentScript.tagName.toUpperCase()&&(d=u.currentScript.src),!d)){var f=u.getElementsByTagName("script");if(f.length)for(var h=f.length-1;h>-1&&(!d||!/^http(s?):/.test(d));)d=f[h--].src}if(!d)throw Error("Automatic publicPath is not supported in this browser");s.p=d=d.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r={261:0},s.f.j=(e,t)=>{var i=s.o(r,e)?r[e]:void 0;if(0!==i)if(i)t.push(i[2]);else{var o=new Promise((t,o)=>i=r[e]=[t,o]);t.push(i[2]=o);var a=s.p+s.u(e),n=Error();s.l(a,t=>{if(s.o(r,e)&&(0!==(i=r[e])&&(r[e]=void 0),i)){var o=t&&("load"===t.type?"missing":t.type),a=t&&t.target&&t.target.src;n.message="Loading chunk "+e+` failed.
|
|
2
|
+
(`+o+": "+a+")",n.name="ChunkLoadError",n.type=o,n.request=a,i[1](n)}},"chunk-"+e,e)}},i=(e,t)=>{var i,o,[a,n,c]=t,p=0;if(a.some(e=>0!==r[e])){for(i in n)s.o(n,i)&&(s.m[i]=n[i]);c&&c(s)}for(e&&e(t);p<a.length;p++)o=a[p],s.o(r,o)&&r[o]&&r[o][0](),r[o]=0},(o=this.webpackChunk_tsparticles_interaction_external_attract=this.webpackChunk_tsparticles_interaction_external_attract||[]).forEach(i.bind(null,0)),o.push=i.bind(null,o.push.bind(o));var b={};s.r(b),s.d(b,{Attract:()=>g.K,loadExternalAttractInteraction:()=>v});var g=s(216);async function v(e){e.checkVersion("4.0.0-beta.0"),await e.register(async e=>{let{ensureInteractivityPluginLoaded:t}=await Promise.resolve().then(s.t.bind(s,702,19));t(e),e.addInteractor?.("externalAttract",async t=>{let{Attractor:r}=await s.e(141).then(s.bind(s,141));return new r(e,t)})})}return b})());
|
package/types/Attractor.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ import { ExternalInteractorBase, type IInteractivityData, type IModes, type Inte
|
|
|
4
4
|
export declare class Attractor extends ExternalInteractorBase<AttractContainer> {
|
|
5
5
|
handleClickMode: (mode: string, interactivityData: IInteractivityData) => void;
|
|
6
6
|
private readonly _engine;
|
|
7
|
+
private _maxDistance;
|
|
7
8
|
constructor(engine: Engine, container: AttractContainer);
|
|
9
|
+
get maxDistance(): number;
|
|
8
10
|
clear(): void;
|
|
9
11
|
init(): void;
|
|
10
12
|
interact(interactivityData: IInteractivityData): void;
|
package/umd/Attractor.js
CHANGED
|
@@ -16,9 +16,13 @@
|
|
|
16
16
|
const Attract_js_1 = require("./Options/Classes/Attract.js");
|
|
17
17
|
const attractMode = "attract";
|
|
18
18
|
class Attractor extends plugin_interactivity_1.ExternalInteractorBase {
|
|
19
|
+
handleClickMode;
|
|
20
|
+
_engine;
|
|
21
|
+
_maxDistance;
|
|
19
22
|
constructor(engine, container) {
|
|
20
23
|
super(container);
|
|
21
24
|
this._engine = engine;
|
|
25
|
+
this._maxDistance = 0;
|
|
22
26
|
container.attract ??= { particles: [] };
|
|
23
27
|
this.handleClickMode = (mode, interactivityData) => {
|
|
24
28
|
const options = this.container.actualOptions, attract = options.interactivity?.modes.attract;
|
|
@@ -45,6 +49,9 @@
|
|
|
45
49
|
}, attract.duration * engine_1.millisecondsToSeconds);
|
|
46
50
|
};
|
|
47
51
|
}
|
|
52
|
+
get maxDistance() {
|
|
53
|
+
return this._maxDistance;
|
|
54
|
+
}
|
|
48
55
|
clear() {
|
|
49
56
|
}
|
|
50
57
|
init() {
|
|
@@ -52,6 +59,7 @@
|
|
|
52
59
|
if (!attract) {
|
|
53
60
|
return;
|
|
54
61
|
}
|
|
62
|
+
this._maxDistance = attract.distance;
|
|
55
63
|
container.retina.attractModeDistance = attract.distance * container.retina.pixelRatio;
|
|
56
64
|
}
|
|
57
65
|
interact(interactivityData) {
|
package/umd/Utils.js
CHANGED
|
@@ -12,16 +12,18 @@
|
|
|
12
12
|
exports.clickAttract = clickAttract;
|
|
13
13
|
exports.hoverAttract = hoverAttract;
|
|
14
14
|
const engine_1 = require("@tsparticles/engine");
|
|
15
|
-
const minFactor = 1, minRadius = 0;
|
|
15
|
+
const minFactor = 1, minRadius = 0, updateVector = engine_1.Vector.origin;
|
|
16
16
|
function processAttract(engine, container, position, attractRadius, area, queryCb) {
|
|
17
17
|
const attractOptions = container.actualOptions.interactivity?.modes.attract;
|
|
18
18
|
if (!attractOptions) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
const query = container.particles.
|
|
21
|
+
const query = container.particles.grid.query(area, queryCb);
|
|
22
22
|
for (const particle of query) {
|
|
23
|
-
const { dx, dy, distance } = (0, engine_1.getDistances)(particle.position, position), velocity = attractOptions.speed * attractOptions.factor, attractFactor = (0, engine_1.clamp)(engine.getEasing(attractOptions.easing)(engine_1.identity - distance / attractRadius) * velocity, minFactor, attractOptions.maxSpeed)
|
|
24
|
-
|
|
23
|
+
const { dx, dy, distance } = (0, engine_1.getDistances)(particle.position, position), velocity = attractOptions.speed * attractOptions.factor, attractFactor = (0, engine_1.clamp)(engine.getEasing(attractOptions.easing)(engine_1.identity - distance / attractRadius) * velocity, minFactor, attractOptions.maxSpeed);
|
|
24
|
+
updateVector.x = !distance ? velocity : (dx / distance) * attractFactor;
|
|
25
|
+
updateVector.y = !distance ? velocity : (dy / distance) * attractFactor;
|
|
26
|
+
particle.position.subFrom(updateVector);
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
function clickAttract(engine, container, interactivityData, enabledCb) {
|
package/umd/index.js
CHANGED
|
@@ -48,10 +48,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
48
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
49
|
exports.loadExternalAttractInteraction = loadExternalAttractInteraction;
|
|
50
50
|
async function loadExternalAttractInteraction(engine) {
|
|
51
|
-
engine.checkVersion("4.0.0-
|
|
51
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
52
52
|
await engine.register(async (e) => {
|
|
53
|
-
const {
|
|
54
|
-
|
|
53
|
+
const { ensureInteractivityPluginLoaded } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("@tsparticles/plugin-interactivity"))) : new Promise((resolve_1, reject_1) => { require(["@tsparticles/plugin-interactivity"], resolve_1, reject_1); }).then(__importStar));
|
|
54
|
+
ensureInteractivityPluginLoaded(e);
|
|
55
55
|
e.addInteractor?.("externalAttract", async (container) => {
|
|
56
56
|
const { Attractor } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Attractor.js"))) : new Promise((resolve_2, reject_2) => { require(["./Attractor.js"], resolve_2, reject_2); }).then(__importStar));
|
|
57
57
|
return new Attractor(e, container);
|
package/689.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! For license information please see 689.min.js.LICENSE.txt */
|
|
2
|
-
(this.webpackChunk_tsparticles_interaction_external_attract=this.webpackChunk_tsparticles_interaction_external_attract||[]).push([[689],{689(t,i,e){e.d(i,{Attractor:()=>r});var n=e(303),a=e(702);function c(t,i,e,a,c,s){const o=i.actualOptions.interactivity?.modes.attract;if(!o)return;const r=i.particles.quadTree.query(c,s);for(const i of r){const{dx:c,dy:s,distance:r}=(0,n.getDistances)(i.position,e),l=o.speed*o.factor,d=(0,n.clamp)(t.getEasing(o.easing)(n.identity-r/a)*l,1,o.maxSpeed),u=n.Vector.create(r?c/r*d:l,r?s/r*d:l);i.position.subFrom(u)}}var s=e(604);const o="attract";class r extends a.ExternalInteractorBase{constructor(t,i){super(i),this._engine=t,i.attract??={particles:[]},this.handleClickMode=(t,e)=>{const a=this.container.actualOptions,c=a.interactivity?.modes.attract;if(c&&t===o){i.attract??={particles:[]},i.attract.clicking=!0,i.attract.count=0;for(const t of i.attract.particles)this.isEnabled(e,t)&&t.velocity.setTo(t.initialVelocity);i.attract.particles=[],i.attract.finish=!1,setTimeout((()=>{i.destroyed||(i.attract??={particles:[]},i.attract.clicking=!1)}),c.duration*n.millisecondsToSeconds)}}}clear(){}init(){const t=this.container,i=t.actualOptions.interactivity?.modes.attract;i&&(t.retina.attractModeDistance=i.distance*t.retina.pixelRatio)}interact(t){const i=this.container.actualOptions,e=t.status===a.mouseMoveEvent,s=i.interactivity?.events;if(!s)return;const{enable:r,mode:l}=s.onHover,{enable:d,mode:u}=s.onClick;e&&r&&(0,n.isInArray)(o,l)?function(t,i,e,a){const s=e.mouse.position,o=i.retina.attractModeDistance;!o||o<0||!s||c(t,i,s,o,new n.Circle(s.x,s.y,o),(t=>a(t)))}(this._engine,this.container,t,(i=>this.isEnabled(t,i))):d&&(0,n.isInArray)(o,u)&&function(t,i,e,a){i.attract??={particles:[]};const{attract:s}=i;if(s.finish||(s.count??=0,s.count++,s.count===i.particles.count&&(s.finish=!0)),s.clicking){const s=e.mouse.clickPosition,o=i.retina.attractModeDistance;if(!o||o<0||!s)return;c(t,i,s,o,new n.Circle(s.x,s.y,o),(t=>a(t)))}else!1===s.clicking&&(s.particles=[])}(this._engine,this.container,t,(i=>this.isEnabled(t,i)))}isEnabled(t,i){const e=this.container.actualOptions,a=t.mouse,c=(i?.interactivity??e.interactivity)?.events;if(!(a.position&&c?.onHover.enable||a.clickPosition&&c?.onClick.enable))return!1;const s=c.onHover.mode,r=c.onClick.mode;return(0,n.isInArray)(o,s)||(0,n.isInArray)(o,r)}loadModeOptions(t,...i){t.attract??=new s.K;for(const e of i)t.attract.load(e?.attract)}reset(){}}}}]);
|
package/689.min.js.LICENSE.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Attract External Interaction v4.0.0-alpha.8 by Matteo Bruni */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Attract External Interaction v4.0.0-alpha.8 by Matteo Bruni */
|