@tsparticles/interaction-external-attract 3.1.0 → 3.2.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,15 @@
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.1.0
7
+ * v3.2.0
8
+ */
9
+ /*
10
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
11
+ * This devtool is neither made for production nor for readable output files.
12
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
13
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
14
+ * or disable the default devtool with "devtool: false".
15
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
8
16
  */
9
17
  (function webpackUniversalModuleDefinition(root, factory) {
10
18
  if(typeof exports === 'object' && typeof module === 'object')
@@ -15,15 +23,38 @@
15
23
  var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
16
24
  for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
17
25
  }
18
- })(this, (__WEBPACK_EXTERNAL_MODULE__533__) => {
26
+ })(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
19
27
  return /******/ (() => { // webpackBootstrap
20
28
  /******/ "use strict";
21
29
  /******/ var __webpack_modules__ = ({
22
30
 
23
- /***/ 533:
31
+ /***/ "./dist/browser/Options/Classes/Attract.js":
32
+ /*!*************************************************!*\
33
+ !*** ./dist/browser/Options/Classes/Attract.js ***!
34
+ \*************************************************/
35
+ /***/ ((__unused_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 */ });\nclass Attract {\n constructor() {\n this.distance = 200;\n this.duration = 0.4;\n this.easing = \"ease-out-quad\";\n this.factor = 1;\n this.maxSpeed = 50;\n this.speed = 1;\n }\n load(data) {\n if (!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?");
38
+
39
+ /***/ }),
40
+
41
+ /***/ "./dist/browser/index.js":
42
+ /*!*******************************!*\
43
+ !*** ./dist/browser/index.js ***!
44
+ \*******************************/
45
+ /***/ ((__unused_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, refresh = true) {\n await engine.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(engine, container);\n }, refresh);\n}\n\n\n\n//# sourceURL=webpack://@tsparticles/interaction-external-attract/./dist/browser/index.js?");
48
+
49
+ /***/ }),
50
+
51
+ /***/ "@tsparticles/engine":
52
+ /*!*********************************************************************************************************************************!*\
53
+ !*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
54
+ \*********************************************************************************************************************************/
24
55
  /***/ ((module) => {
25
56
 
26
- module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
57
+ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
27
58
 
28
59
  /***/ })
29
60
 
@@ -53,7 +84,22 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
53
84
  /******/ return module.exports;
54
85
  /******/ }
55
86
  /******/
87
+ /******/ // expose the modules object (__webpack_modules__)
88
+ /******/ __webpack_require__.m = __webpack_modules__;
89
+ /******/
56
90
  /************************************************************************/
91
+ /******/ /* webpack/runtime/compat get default export */
92
+ /******/ (() => {
93
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
94
+ /******/ __webpack_require__.n = (module) => {
95
+ /******/ var getter = module && module.__esModule ?
96
+ /******/ () => (module['default']) :
97
+ /******/ () => (module);
98
+ /******/ __webpack_require__.d(getter, { a: getter });
99
+ /******/ return getter;
100
+ /******/ };
101
+ /******/ })();
102
+ /******/
57
103
  /******/ /* webpack/runtime/define property getters */
58
104
  /******/ (() => {
59
105
  /******/ // define getter functions for harmony exports
@@ -66,11 +112,91 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
66
112
  /******/ };
67
113
  /******/ })();
68
114
  /******/
115
+ /******/ /* webpack/runtime/ensure chunk */
116
+ /******/ (() => {
117
+ /******/ __webpack_require__.f = {};
118
+ /******/ // This file contains only the entry chunk.
119
+ /******/ // The chunk loading function for additional chunks
120
+ /******/ __webpack_require__.e = (chunkId) => {
121
+ /******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
122
+ /******/ __webpack_require__.f[key](chunkId, promises);
123
+ /******/ return promises;
124
+ /******/ }, []));
125
+ /******/ };
126
+ /******/ })();
127
+ /******/
128
+ /******/ /* webpack/runtime/get javascript chunk filename */
129
+ /******/ (() => {
130
+ /******/ // This function allow to reference async chunks
131
+ /******/ __webpack_require__.u = (chunkId) => {
132
+ /******/ // return url for filenames based on template
133
+ /******/ return "" + chunkId + ".js";
134
+ /******/ };
135
+ /******/ })();
136
+ /******/
137
+ /******/ /* webpack/runtime/global */
138
+ /******/ (() => {
139
+ /******/ __webpack_require__.g = (function() {
140
+ /******/ if (typeof globalThis === 'object') return globalThis;
141
+ /******/ try {
142
+ /******/ return this || new Function('return this')();
143
+ /******/ } catch (e) {
144
+ /******/ if (typeof window === 'object') return window;
145
+ /******/ }
146
+ /******/ })();
147
+ /******/ })();
148
+ /******/
69
149
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
70
150
  /******/ (() => {
71
151
  /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
72
152
  /******/ })();
73
153
  /******/
154
+ /******/ /* webpack/runtime/load script */
155
+ /******/ (() => {
156
+ /******/ var inProgress = {};
157
+ /******/ var dataWebpackPrefix = "@tsparticles/interaction-external-attract:";
158
+ /******/ // loadScript function to load a script via script tag
159
+ /******/ __webpack_require__.l = (url, done, key, chunkId) => {
160
+ /******/ if(inProgress[url]) { inProgress[url].push(done); return; }
161
+ /******/ var script, needAttach;
162
+ /******/ if(key !== undefined) {
163
+ /******/ var scripts = document.getElementsByTagName("script");
164
+ /******/ for(var i = 0; i < scripts.length; i++) {
165
+ /******/ var s = scripts[i];
166
+ /******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
167
+ /******/ }
168
+ /******/ }
169
+ /******/ if(!script) {
170
+ /******/ needAttach = true;
171
+ /******/ script = document.createElement('script');
172
+ /******/
173
+ /******/ script.charset = 'utf-8';
174
+ /******/ script.timeout = 120;
175
+ /******/ if (__webpack_require__.nc) {
176
+ /******/ script.setAttribute("nonce", __webpack_require__.nc);
177
+ /******/ }
178
+ /******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
179
+ /******/
180
+ /******/ script.src = url;
181
+ /******/ }
182
+ /******/ inProgress[url] = [done];
183
+ /******/ var onScriptComplete = (prev, event) => {
184
+ /******/ // avoid mem leaks in IE.
185
+ /******/ script.onerror = script.onload = null;
186
+ /******/ clearTimeout(timeout);
187
+ /******/ var doneFns = inProgress[url];
188
+ /******/ delete inProgress[url];
189
+ /******/ script.parentNode && script.parentNode.removeChild(script);
190
+ /******/ doneFns && doneFns.forEach((fn) => (fn(event)));
191
+ /******/ if(prev) return prev(event);
192
+ /******/ }
193
+ /******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
194
+ /******/ script.onerror = onScriptComplete.bind(null, script.onerror);
195
+ /******/ script.onload = onScriptComplete.bind(null, script.onload);
196
+ /******/ needAttach && document.head.appendChild(script);
197
+ /******/ };
198
+ /******/ })();
199
+ /******/
74
200
  /******/ /* webpack/runtime/make namespace object */
75
201
  /******/ (() => {
76
202
  /******/ // define __esModule on exports
@@ -82,219 +208,128 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
82
208
  /******/ };
83
209
  /******/ })();
84
210
  /******/
211
+ /******/ /* webpack/runtime/publicPath */
212
+ /******/ (() => {
213
+ /******/ var scriptUrl;
214
+ /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
215
+ /******/ var document = __webpack_require__.g.document;
216
+ /******/ if (!scriptUrl && document) {
217
+ /******/ if (document.currentScript)
218
+ /******/ scriptUrl = document.currentScript.src;
219
+ /******/ if (!scriptUrl) {
220
+ /******/ var scripts = document.getElementsByTagName("script");
221
+ /******/ if(scripts.length) {
222
+ /******/ var i = scripts.length - 1;
223
+ /******/ while (i > -1 && !scriptUrl) scriptUrl = scripts[i--].src;
224
+ /******/ }
225
+ /******/ }
226
+ /******/ }
227
+ /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
228
+ /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
229
+ /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
230
+ /******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
231
+ /******/ __webpack_require__.p = scriptUrl;
232
+ /******/ })();
233
+ /******/
234
+ /******/ /* webpack/runtime/jsonp chunk loading */
235
+ /******/ (() => {
236
+ /******/ // no baseURI
237
+ /******/
238
+ /******/ // object to store loaded and loading chunks
239
+ /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
240
+ /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
241
+ /******/ var installedChunks = {
242
+ /******/ "tsparticles.interaction.external.attract": 0
243
+ /******/ };
244
+ /******/
245
+ /******/ __webpack_require__.f.j = (chunkId, promises) => {
246
+ /******/ // JSONP chunk loading for javascript
247
+ /******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
248
+ /******/ if(installedChunkData !== 0) { // 0 means "already installed".
249
+ /******/
250
+ /******/ // a Promise means "currently loading".
251
+ /******/ if(installedChunkData) {
252
+ /******/ promises.push(installedChunkData[2]);
253
+ /******/ } else {
254
+ /******/ if(true) { // all chunks have JS
255
+ /******/ // setup Promise in chunk cache
256
+ /******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
257
+ /******/ promises.push(installedChunkData[2] = promise);
258
+ /******/
259
+ /******/ // start chunk loading
260
+ /******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
261
+ /******/ // create error before stack unwound to get useful stacktrace later
262
+ /******/ var error = new Error();
263
+ /******/ var loadingEnded = (event) => {
264
+ /******/ if(__webpack_require__.o(installedChunks, chunkId)) {
265
+ /******/ installedChunkData = installedChunks[chunkId];
266
+ /******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
267
+ /******/ if(installedChunkData) {
268
+ /******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
269
+ /******/ var realSrc = event && event.target && event.target.src;
270
+ /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
271
+ /******/ error.name = 'ChunkLoadError';
272
+ /******/ error.type = errorType;
273
+ /******/ error.request = realSrc;
274
+ /******/ installedChunkData[1](error);
275
+ /******/ }
276
+ /******/ }
277
+ /******/ };
278
+ /******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
279
+ /******/ }
280
+ /******/ }
281
+ /******/ }
282
+ /******/ };
283
+ /******/
284
+ /******/ // no prefetching
285
+ /******/
286
+ /******/ // no preloaded
287
+ /******/
288
+ /******/ // no HMR
289
+ /******/
290
+ /******/ // no HMR manifest
291
+ /******/
292
+ /******/ // no on chunks loaded
293
+ /******/
294
+ /******/ // install a JSONP callback for chunk loading
295
+ /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
296
+ /******/ var chunkIds = data[0];
297
+ /******/ var moreModules = data[1];
298
+ /******/ var runtime = data[2];
299
+ /******/ // add "moreModules" to the modules object,
300
+ /******/ // then flag all "chunkIds" as loaded and fire callback
301
+ /******/ var moduleId, chunkId, i = 0;
302
+ /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
303
+ /******/ for(moduleId in moreModules) {
304
+ /******/ if(__webpack_require__.o(moreModules, moduleId)) {
305
+ /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
306
+ /******/ }
307
+ /******/ }
308
+ /******/ if(runtime) var result = runtime(__webpack_require__);
309
+ /******/ }
310
+ /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
311
+ /******/ for(;i < chunkIds.length; i++) {
312
+ /******/ chunkId = chunkIds[i];
313
+ /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
314
+ /******/ installedChunks[chunkId][0]();
315
+ /******/ }
316
+ /******/ installedChunks[chunkId] = 0;
317
+ /******/ }
318
+ /******/
319
+ /******/ }
320
+ /******/
321
+ /******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_interaction_external_attract"] = this["webpackChunk_tsparticles_interaction_external_attract"] || [];
322
+ /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
323
+ /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
324
+ /******/ })();
325
+ /******/
85
326
  /************************************************************************/
86
- var __webpack_exports__ = {};
87
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
88
- (() => {
89
- // ESM COMPAT FLAG
90
- __webpack_require__.r(__webpack_exports__);
91
-
92
- // EXPORTS
93
- __webpack_require__.d(__webpack_exports__, {
94
- Attract: () => (/* reexport */ Attract),
95
- loadExternalAttractInteraction: () => (/* binding */ loadExternalAttractInteraction)
96
- });
97
-
98
- // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
99
- var engine_root_window_ = __webpack_require__(533);
100
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Attract.js
101
- class Attract {
102
- constructor() {
103
- this.distance = 200;
104
- this.duration = 0.4;
105
- this.easing = "ease-out-quad";
106
- this.factor = 1;
107
- this.maxSpeed = 50;
108
- this.speed = 1;
109
- }
110
- load(data) {
111
- if (!data) {
112
- return;
113
- }
114
- if (data.distance !== undefined) {
115
- this.distance = data.distance;
116
- }
117
- if (data.duration !== undefined) {
118
- this.duration = data.duration;
119
- }
120
- if (data.easing !== undefined) {
121
- this.easing = data.easing;
122
- }
123
- if (data.factor !== undefined) {
124
- this.factor = data.factor;
125
- }
126
- if (data.maxSpeed !== undefined) {
127
- this.maxSpeed = data.maxSpeed;
128
- }
129
- if (data.speed !== undefined) {
130
- this.speed = data.speed;
131
- }
132
- }
133
- }
134
- ;// CONCATENATED MODULE: ./dist/browser/Attractor.js
135
-
136
-
137
- const attractMode = "attract",
138
- minRadius = 0,
139
- minFactor = 1,
140
- identity = 1;
141
- class Attractor extends engine_root_window_.ExternalInteractorBase {
142
- constructor(engine, container) {
143
- super(container);
144
- this._clickAttract = () => {
145
- const container = this.container;
146
- if (!container.attract) {
147
- container.attract = {
148
- particles: []
149
- };
150
- }
151
- const {
152
- attract
153
- } = container;
154
- if (!attract.finish) {
155
- if (!attract.count) {
156
- attract.count = 0;
157
- }
158
- attract.count++;
159
- if (attract.count === container.particles.count) {
160
- attract.finish = true;
161
- }
162
- }
163
- if (attract.clicking) {
164
- const mousePos = container.interactivity.mouse.clickPosition,
165
- attractRadius = container.retina.attractModeDistance;
166
- if (!attractRadius || attractRadius < minRadius || !mousePos) {
167
- return;
168
- }
169
- this._processAttract(mousePos, attractRadius, new engine_root_window_.Circle(mousePos.x, mousePos.y, attractRadius));
170
- } else if (attract.clicking === false) {
171
- attract.particles = [];
172
- }
173
- };
174
- this._hoverAttract = () => {
175
- const container = this.container,
176
- mousePos = container.interactivity.mouse.position,
177
- attractRadius = container.retina.attractModeDistance;
178
- if (!attractRadius || attractRadius < minRadius || !mousePos) {
179
- return;
180
- }
181
- this._processAttract(mousePos, attractRadius, new engine_root_window_.Circle(mousePos.x, mousePos.y, attractRadius));
182
- };
183
- this._processAttract = (position, attractRadius, area) => {
184
- const container = this.container,
185
- attractOptions = container.actualOptions.interactivity.modes.attract;
186
- if (!attractOptions) {
187
- return;
188
- }
189
- const query = container.particles.quadTree.query(area, p => this.isEnabled(p));
190
- for (const particle of query) {
191
- const {
192
- dx,
193
- dy,
194
- distance
195
- } = (0,engine_root_window_.getDistances)(particle.position, position),
196
- velocity = attractOptions.speed * attractOptions.factor,
197
- attractFactor = (0,engine_root_window_.clamp)((0,engine_root_window_.getEasing)(attractOptions.easing)(identity - distance / attractRadius) * velocity, minFactor, attractOptions.maxSpeed),
198
- normVec = engine_root_window_.Vector.create(!distance ? velocity : dx / distance * attractFactor, !distance ? velocity : dy / distance * attractFactor);
199
- particle.position.subFrom(normVec);
200
- }
201
- };
202
- this._engine = engine;
203
- if (!container.attract) {
204
- container.attract = {
205
- particles: []
206
- };
207
- }
208
- this.handleClickMode = mode => {
209
- const options = this.container.actualOptions,
210
- attract = options.interactivity.modes.attract;
211
- if (!attract || mode !== attractMode) {
212
- return;
213
- }
214
- if (!container.attract) {
215
- container.attract = {
216
- particles: []
217
- };
218
- }
219
- container.attract.clicking = true;
220
- container.attract.count = 0;
221
- for (const particle of container.attract.particles) {
222
- if (!this.isEnabled(particle)) {
223
- continue;
224
- }
225
- particle.velocity.setTo(particle.initialVelocity);
226
- }
227
- container.attract.particles = [];
228
- container.attract.finish = false;
229
- setTimeout(() => {
230
- if (container.destroyed) {
231
- return;
232
- }
233
- if (!container.attract) {
234
- container.attract = {
235
- particles: []
236
- };
237
- }
238
- container.attract.clicking = false;
239
- }, attract.duration * engine_root_window_.millisecondsToSeconds);
240
- };
241
- }
242
- clear() {}
243
- init() {
244
- const container = this.container,
245
- attract = container.actualOptions.interactivity.modes.attract;
246
- if (!attract) {
247
- return;
248
- }
249
- container.retina.attractModeDistance = attract.distance * container.retina.pixelRatio;
250
- }
251
- async interact() {
252
- const container = this.container,
253
- options = container.actualOptions,
254
- mouseMoveStatus = container.interactivity.status === engine_root_window_.mouseMoveEvent,
255
- events = options.interactivity.events,
256
- hoverEnabled = events.onHover.enable,
257
- hoverMode = events.onHover.mode,
258
- clickEnabled = events.onClick.enable,
259
- clickMode = events.onClick.mode;
260
- if (mouseMoveStatus && hoverEnabled && (0,engine_root_window_.isInArray)(attractMode, hoverMode)) {
261
- this._hoverAttract();
262
- } else if (clickEnabled && (0,engine_root_window_.isInArray)(attractMode, clickMode)) {
263
- this._clickAttract();
264
- }
265
- await Promise.resolve();
266
- }
267
- isEnabled(particle) {
268
- const container = this.container,
269
- options = container.actualOptions,
270
- mouse = container.interactivity.mouse,
271
- events = (particle?.interactivity ?? options.interactivity).events;
272
- if ((!mouse.position || !events.onHover.enable) && (!mouse.clickPosition || !events.onClick.enable)) {
273
- return false;
274
- }
275
- const hoverMode = events.onHover.mode,
276
- clickMode = events.onClick.mode;
277
- return (0,engine_root_window_.isInArray)(attractMode, hoverMode) || (0,engine_root_window_.isInArray)(attractMode, clickMode);
278
- }
279
- loadModeOptions(options, ...sources) {
280
- if (!options.attract) {
281
- options.attract = new Attract();
282
- }
283
- for (const source of sources) {
284
- options.attract.load(source?.attract);
285
- }
286
- }
287
- reset() {}
288
- }
289
- ;// CONCATENATED MODULE: ./dist/browser/index.js
290
-
291
- async function loadExternalAttractInteraction(engine, refresh = true) {
292
- await engine.addInteractor("externalAttract", container => new Attractor(engine, container), refresh);
293
- }
294
-
295
-
296
- })();
297
-
327
+ /******/
328
+ /******/ // startup
329
+ /******/ // Load entry module and return exports
330
+ /******/ // This entry module can't be inlined because the eval devtool is used.
331
+ /******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
332
+ /******/
298
333
  /******/ return __webpack_exports__;
299
334
  /******/ })()
300
335
  ;
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.interaction.external.attract.min.js.LICENSE.txt */
2
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],e);else{var i="object"==typeof exports?e(require("@tsparticles/engine")):e(t.window);for(var a in i)("object"==typeof exports?exports:t)[a]=i[a]}}(this,(t=>(()=>{"use strict";var e={533:e=>{e.exports=t}},i={};function a(t){var r=i[t];if(void 0!==r)return r.exports;var o=i[t]={exports:{}};return e[t](o,o.exports,a),o.exports}a.d=(t,e)=>{for(var i in e)a.o(e,i)&&!a.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{a.r(r),a.d(r,{Attract:()=>e,loadExternalAttractInteraction:()=>n});var t=a(533);class e{constructor(){this.distance=200,this.duration=.4,this.easing="ease-out-quad",this.factor=1,this.maxSpeed=50,this.speed=1}load(t){t&&(void 0!==t.distance&&(this.distance=t.distance),void 0!==t.duration&&(this.duration=t.duration),void 0!==t.easing&&(this.easing=t.easing),void 0!==t.factor&&(this.factor=t.factor),void 0!==t.maxSpeed&&(this.maxSpeed=t.maxSpeed),void 0!==t.speed&&(this.speed=t.speed))}}const i="attract";class o extends t.ExternalInteractorBase{constructor(e,a){super(a),this._clickAttract=()=>{const e=this.container;e.attract||(e.attract={particles:[]});const{attract:i}=e;if(i.finish||(i.count||(i.count=0),i.count++,i.count===e.particles.count&&(i.finish=!0)),i.clicking){const i=e.interactivity.mouse.clickPosition,a=e.retina.attractModeDistance;if(!a||a<0||!i)return;this._processAttract(i,a,new t.Circle(i.x,i.y,a))}else!1===i.clicking&&(i.particles=[])},this._hoverAttract=()=>{const e=this.container,i=e.interactivity.mouse.position,a=e.retina.attractModeDistance;!a||a<0||!i||this._processAttract(i,a,new t.Circle(i.x,i.y,a))},this._processAttract=(e,i,a)=>{const r=this.container,o=r.actualOptions.interactivity.modes.attract;if(!o)return;const n=r.particles.quadTree.query(a,(t=>this.isEnabled(t)));for(const a of n){const{dx:r,dy:n,distance:c}=(0,t.getDistances)(a.position,e),s=o.speed*o.factor,d=(0,t.clamp)((0,t.getEasing)(o.easing)(1-c/i)*s,1,o.maxSpeed),l=t.Vector.create(c?r/c*d:s,c?n/c*d:s);a.position.subFrom(l)}},this._engine=e,a.attract||(a.attract={particles:[]}),this.handleClickMode=e=>{const r=this.container.actualOptions.interactivity.modes.attract;if(r&&e===i){a.attract||(a.attract={particles:[]}),a.attract.clicking=!0,a.attract.count=0;for(const t of a.attract.particles)this.isEnabled(t)&&t.velocity.setTo(t.initialVelocity);a.attract.particles=[],a.attract.finish=!1,setTimeout((()=>{a.destroyed||(a.attract||(a.attract={particles:[]}),a.attract.clicking=!1)}),r.duration*t.millisecondsToSeconds)}}}clear(){}init(){const t=this.container,e=t.actualOptions.interactivity.modes.attract;e&&(t.retina.attractModeDistance=e.distance*t.retina.pixelRatio)}async interact(){const e=this.container,a=e.actualOptions,r=e.interactivity.status===t.mouseMoveEvent,o=a.interactivity.events,n=o.onHover.enable,c=o.onHover.mode,s=o.onClick.enable,d=o.onClick.mode;r&&n&&(0,t.isInArray)(i,c)?this._hoverAttract():s&&(0,t.isInArray)(i,d)&&this._clickAttract(),await Promise.resolve()}isEnabled(e){const a=this.container,r=a.actualOptions,o=a.interactivity.mouse,n=(e?.interactivity??r.interactivity).events;if(!(o.position&&n.onHover.enable||o.clickPosition&&n.onClick.enable))return!1;const c=n.onHover.mode,s=n.onClick.mode;return(0,t.isInArray)(i,c)||(0,t.isInArray)(i,s)}loadModeOptions(t,...i){t.attract||(t.attract=new e);for(const e of i)t.attract.load(e?.attract)}reset(){}}async function n(t,e=!0){await t.addInteractor("externalAttract",(e=>new o(t,e)),e)}})(),r})()));
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=>(()=>{var t,r,o={368:(e,t,r)=>{r.d(t,{L:()=>o});class o{constructor(){this.distance=200,this.duration=.4,this.easing="ease-out-quad",this.factor=1,this.maxSpeed=50,this.speed=1}load(e){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))}}},533:t=>{t.exports=e}},a={};function i(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return o[e](r,r.exports,i),r.exports}i.m=o,i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce(((t,r)=>(i.f[r](e,t),t)),[])),i.u=e=>e+".min.js",i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},r="@tsparticles/interaction-external-attract:",i.l=(e,o,a,n)=>{if(t[e])t[e].push(o);else{var s,c;if(void 0!==a)for(var d=document.getElementsByTagName("script"),l=0;l<d.length;l++){var u=d[l];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==r+a){s=u;break}}s||(c=!0,(s=document.createElement("script")).charset="utf-8",s.timeout=120,i.nc&&s.setAttribute("nonce",i.nc),s.setAttribute("data-webpack",r+a),s.src=e),t[e]=[o];var p=(r,o)=>{s.onerror=s.onload=null,clearTimeout(f);var a=t[e];if(delete t[e],s.parentNode&&s.parentNode.removeChild(s),a&&a.forEach((e=>e(o))),r)return r(o)},f=setTimeout(p.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=p.bind(null,s.onerror),s.onload=p.bind(null,s.onload),c&&document.head.appendChild(s)}},i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;i.g.importScripts&&(e=i.g.location+"");var t=i.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&!e;)e=r[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=e})(),(()=>{var e={563:0};i.f.j=(t,r)=>{var o=i.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var a=new Promise(((r,a)=>o=e[t]=[r,a]));r.push(o[2]=a);var n=i.p+i.u(t),s=new Error;i.l(n,(r=>{if(i.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var a=r&&("load"===r.type?"missing":r.type),n=r&&r.target&&r.target.src;s.message="Loading chunk "+t+" failed.\n("+a+": "+n+")",s.name="ChunkLoadError",s.type=a,s.request=n,o[1](s)}}),"chunk-"+t,t)}};var t=(t,r)=>{var o,a,n=r[0],s=r[1],c=r[2],d=0;if(n.some((t=>0!==e[t]))){for(o in s)i.o(s,o)&&(i.m[o]=s[o]);if(c)c(i)}for(t&&t(r);d<n.length;d++)a=n[d],i.o(e,a)&&e[a]&&e[a][0](),e[a]=0},r=this.webpackChunk_tsparticles_interaction_external_attract=this.webpackChunk_tsparticles_interaction_external_attract||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var n={};return(()=>{i.r(n),i.d(n,{Attract:()=>e.L,loadExternalAttractInteraction:()=>t});var e=i(368);async function t(e,t=!0){await e.addInteractor("externalAttract",(async t=>{const{Attractor:r}=await i.e(696).then(i.bind(i,696));return new r(e,t)}),t)}})(),n})()));
@@ -1 +1 @@
1
- /*! tsParticles Attract External Interaction v3.1.0 by Matteo Bruni */
1
+ /*! tsParticles Attract External Interaction v3.2.0 by Matteo Bruni */
@@ -10,7 +10,4 @@ export declare class Attractor extends ExternalInteractorBase<AttractContainer>
10
10
  isEnabled(particle?: Particle): boolean;
11
11
  loadModeOptions(options: Modes & AttractMode, ...sources: RecursivePartial<(IModes & IAttractMode) | undefined>[]): void;
12
12
  reset(): void;
13
- private readonly _clickAttract;
14
- private readonly _hoverAttract;
15
- private readonly _processAttract;
16
13
  }
@@ -0,0 +1,4 @@
1
+ import { type Particle } from "@tsparticles/engine";
2
+ import type { AttractContainer } from "./Types.js";
3
+ export declare function clickAttract(container: AttractContainer, enabledCb: (particle: Particle) => boolean): void;
4
+ export declare function hoverAttract(container: AttractContainer, enabledCb: (particle: Particle) => boolean): void;