@tsparticles/interaction-external-attract 3.9.1 → 4.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.9.1
7
+ * v4.0.0-alpha.1
8
8
  */
9
9
  /*
10
10
  * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
@@ -28,55 +28,35 @@ return /******/ (() => { // webpackBootstrap
28
28
  /******/ "use strict";
29
29
  /******/ var __webpack_modules__ = ({
30
30
 
31
- /***/ "./dist/browser/Attractor.js":
32
- /*!***********************************!*\
33
- !*** ./dist/browser/Attractor.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 */ 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_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n/* harmony import */ var _Options_Classes_Attract_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Options/Classes/Attract.js */ \"./dist/browser/Options/Classes/Attract.js\");\n\n\n\nconst attractMode = \"attract\";\nclass Attractor extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ExternalInteractorBase {\n constructor(engine, container) {\n super(container);\n this._engine = engine;\n if (!container.attract) {\n container.attract = {\n particles: []\n };\n }\n this.handleClickMode = mode => {\n const options = this.container.actualOptions,\n attract = options.interactivity.modes.attract;\n if (!attract || mode !== attractMode) {\n return;\n }\n if (!container.attract) {\n container.attract = {\n particles: []\n };\n }\n container.attract.clicking = true;\n container.attract.count = 0;\n for (const particle of container.attract.particles) {\n if (!this.isEnabled(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 if (!container.attract) {\n container.attract = {\n particles: []\n };\n }\n container.attract.clicking = false;\n }, attract.duration * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.millisecondsToSeconds);\n };\n }\n clear() {}\n init() {\n const container = this.container,\n attract = container.actualOptions.interactivity.modes.attract;\n if (!attract) {\n return;\n }\n container.retina.attractModeDistance = attract.distance * container.retina.pixelRatio;\n }\n interact() {\n const container = this.container,\n options = container.actualOptions,\n mouseMoveStatus = container.interactivity.status === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.mouseMoveEvent,\n events = options.interactivity.events,\n {\n enable: hoverEnabled,\n mode: hoverMode\n } = events.onHover,\n {\n enable: clickEnabled,\n mode: clickMode\n } = events.onClick;\n if (mouseMoveStatus && hoverEnabled && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(attractMode, hoverMode)) {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.hoverAttract)(this._engine, this.container, p => this.isEnabled(p));\n } else if (clickEnabled && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(attractMode, clickMode)) {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.clickAttract)(this._engine, this.container, p => this.isEnabled(p));\n }\n }\n isEnabled(particle) {\n const container = this.container,\n options = container.actualOptions,\n mouse = container.interactivity.mouse,\n 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,\n 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 if (!options.attract) {\n options.attract = new _Options_Classes_Attract_js__WEBPACK_IMPORTED_MODULE_2__.Attract();\n }\n for (const source of sources) {\n options.attract.load(source?.attract);\n }\n }\n reset() {}\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-external-attract/./dist/browser/Attractor.js?\n}");
38
-
39
- /***/ }),
40
-
41
- /***/ "./dist/browser/Options/Classes/Attract.js":
31
+ /***/ "./dist/browser/Options/Classes/Attract.js"
42
32
  /*!*************************************************!*\
43
33
  !*** ./dist/browser/Options/Classes/Attract.js ***!
44
34
  \*************************************************/
45
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
35
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
46
36
 
47
- 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/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\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}");
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}");
48
38
 
49
- /***/ }),
39
+ /***/ },
50
40
 
51
- /***/ "./dist/browser/Utils.js":
52
- /*!*******************************!*\
53
- !*** ./dist/browser/Utils.js ***!
54
- \*******************************/
55
- /***/ ((__unused_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 */ 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/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nconst minFactor = 1,\n identity = 1,\n minRadius = 0;\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.quadTree.query(area, queryCb);\n for (const particle of query) {\n const {\n dx,\n dy,\n distance\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(particle.position, position),\n velocity = attractOptions.speed * attractOptions.factor,\n attractFactor = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.clamp)(engine.getEasing(attractOptions.easing)(identity - distance / attractRadius) * velocity, minFactor, attractOptions.maxSpeed),\n normVec = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.create(!distance ? velocity : dx / distance * attractFactor, !distance ? velocity : dy / distance * attractFactor);\n particle.position.subFrom(normVec);\n }\n}\nfunction clickAttract(engine, container, enabledCb) {\n if (!container.attract) {\n container.attract = {\n particles: []\n };\n }\n const {\n attract\n } = container;\n if (!attract.finish) {\n if (!attract.count) {\n attract.count = 0;\n }\n attract.count++;\n if (attract.count === container.particles.count) {\n attract.finish = true;\n }\n }\n if (attract.clicking) {\n const mousePos = container.interactivity.mouse.clickPosition,\n 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, enabledCb) {\n const mousePos = container.interactivity.mouse.position,\n 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//# sourceURL=webpack://@tsparticles/interaction-external-attract/./dist/browser/Utils.js?\n}");
58
-
59
- /***/ }),
60
-
61
- /***/ "./dist/browser/index.js":
41
+ /***/ "./dist/browser/index.js"
62
42
  /*!*******************************!*\
63
43
  !*** ./dist/browser/index.js ***!
64
44
  \*******************************/
65
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
45
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
66
46
 
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_1__.Attract),\n/* harmony export */ loadExternalAttractInteraction: () => (/* binding */ loadExternalAttractInteraction)\n/* harmony export */ });\n/* harmony import */ var _Attractor_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Attractor.js */ \"./dist/browser/Attractor.js\");\n/* harmony import */ var _Options_Classes_Attract_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/Attract.js */ \"./dist/browser/Options/Classes/Attract.js\");\n\nasync function loadExternalAttractInteraction(engine, refresh = true) {\n engine.checkVersion(\"3.9.1\");\n await engine.addInteractor(\"externalAttract\", container => {\n return Promise.resolve(new _Attractor_js__WEBPACK_IMPORTED_MODULE_0__.Attractor(engine, container));\n }, refresh);\n}\n\n\n\n//# sourceURL=webpack://@tsparticles/interaction-external-attract/./dist/browser/index.js?\n}");
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\");\nfunction loadExternalAttractInteraction(engine) {\n engine.checkVersion(\"4.0.0-alpha.1\");\n engine.register(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}");
68
48
 
69
- /***/ }),
49
+ /***/ },
70
50
 
71
- /***/ "@tsparticles/engine":
51
+ /***/ "@tsparticles/engine"
72
52
  /*!*********************************************************************************************************************************!*\
73
53
  !*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
74
54
  \*********************************************************************************************************************************/
75
- /***/ ((module) => {
55
+ (module) {
76
56
 
77
57
  module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
78
58
 
79
- /***/ })
59
+ /***/ }
80
60
 
81
61
  /******/ });
82
62
  /************************************************************************/
@@ -90,6 +70,12 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
90
70
  /******/ if (cachedModule !== undefined) {
91
71
  /******/ return cachedModule.exports;
92
72
  /******/ }
73
+ /******/ // Check if module exists (development only)
74
+ /******/ if (__webpack_modules__[moduleId] === undefined) {
75
+ /******/ var e = new Error("Cannot find module '" + moduleId + "'");
76
+ /******/ e.code = 'MODULE_NOT_FOUND';
77
+ /******/ throw e;
78
+ /******/ }
93
79
  /******/ // Create a new module (and put it into the cache)
94
80
  /******/ var module = __webpack_module_cache__[moduleId] = {
95
81
  /******/ // no module.id needed
@@ -104,19 +90,10 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
104
90
  /******/ return module.exports;
105
91
  /******/ }
106
92
  /******/
107
- /************************************************************************/
108
- /******/ /* webpack/runtime/compat get default export */
109
- /******/ (() => {
110
- /******/ // getDefaultExport function for compatibility with non-harmony modules
111
- /******/ __webpack_require__.n = (module) => {
112
- /******/ var getter = module && module.__esModule ?
113
- /******/ () => (module['default']) :
114
- /******/ () => (module);
115
- /******/ __webpack_require__.d(getter, { a: getter });
116
- /******/ return getter;
117
- /******/ };
118
- /******/ })();
93
+ /******/ // expose the modules object (__webpack_modules__)
94
+ /******/ __webpack_require__.m = __webpack_modules__;
119
95
  /******/
96
+ /************************************************************************/
120
97
  /******/ /* webpack/runtime/define property getters */
121
98
  /******/ (() => {
122
99
  /******/ // define getter functions for harmony exports
@@ -129,11 +106,90 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
129
106
  /******/ };
130
107
  /******/ })();
131
108
  /******/
109
+ /******/ /* webpack/runtime/ensure chunk */
110
+ /******/ (() => {
111
+ /******/ __webpack_require__.f = {};
112
+ /******/ // This file contains only the entry chunk.
113
+ /******/ // The chunk loading function for additional chunks
114
+ /******/ __webpack_require__.e = (chunkId) => {
115
+ /******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
116
+ /******/ __webpack_require__.f[key](chunkId, promises);
117
+ /******/ return promises;
118
+ /******/ }, []));
119
+ /******/ };
120
+ /******/ })();
121
+ /******/
122
+ /******/ /* webpack/runtime/get javascript chunk filename */
123
+ /******/ (() => {
124
+ /******/ // This function allow to reference async chunks
125
+ /******/ __webpack_require__.u = (chunkId) => {
126
+ /******/ // return url for filenames based on template
127
+ /******/ return "" + chunkId + ".js";
128
+ /******/ };
129
+ /******/ })();
130
+ /******/
131
+ /******/ /* webpack/runtime/global */
132
+ /******/ (() => {
133
+ /******/ __webpack_require__.g = (function() {
134
+ /******/ if (typeof globalThis === 'object') return globalThis;
135
+ /******/ try {
136
+ /******/ return this || new Function('return this')();
137
+ /******/ } catch (e) {
138
+ /******/ if (typeof window === 'object') return window;
139
+ /******/ }
140
+ /******/ })();
141
+ /******/ })();
142
+ /******/
132
143
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
133
144
  /******/ (() => {
134
145
  /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
135
146
  /******/ })();
136
147
  /******/
148
+ /******/ /* webpack/runtime/load script */
149
+ /******/ (() => {
150
+ /******/ var inProgress = {};
151
+ /******/ var dataWebpackPrefix = "@tsparticles/interaction-external-attract:";
152
+ /******/ // loadScript function to load a script via script tag
153
+ /******/ __webpack_require__.l = (url, done, key, chunkId) => {
154
+ /******/ if(inProgress[url]) { inProgress[url].push(done); return; }
155
+ /******/ var script, needAttach;
156
+ /******/ if(key !== undefined) {
157
+ /******/ var scripts = document.getElementsByTagName("script");
158
+ /******/ for(var i = 0; i < scripts.length; i++) {
159
+ /******/ var s = scripts[i];
160
+ /******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
161
+ /******/ }
162
+ /******/ }
163
+ /******/ if(!script) {
164
+ /******/ needAttach = true;
165
+ /******/ script = document.createElement('script');
166
+ /******/
167
+ /******/ script.charset = 'utf-8';
168
+ /******/ if (__webpack_require__.nc) {
169
+ /******/ script.setAttribute("nonce", __webpack_require__.nc);
170
+ /******/ }
171
+ /******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
172
+ /******/
173
+ /******/ script.src = url;
174
+ /******/ }
175
+ /******/ inProgress[url] = [done];
176
+ /******/ var onScriptComplete = (prev, event) => {
177
+ /******/ // avoid mem leaks in IE.
178
+ /******/ script.onerror = script.onload = null;
179
+ /******/ clearTimeout(timeout);
180
+ /******/ var doneFns = inProgress[url];
181
+ /******/ delete inProgress[url];
182
+ /******/ script.parentNode && script.parentNode.removeChild(script);
183
+ /******/ doneFns && doneFns.forEach((fn) => (fn(event)));
184
+ /******/ if(prev) return prev(event);
185
+ /******/ }
186
+ /******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
187
+ /******/ script.onerror = onScriptComplete.bind(null, script.onerror);
188
+ /******/ script.onload = onScriptComplete.bind(null, script.onload);
189
+ /******/ needAttach && document.head.appendChild(script);
190
+ /******/ };
191
+ /******/ })();
192
+ /******/
137
193
  /******/ /* webpack/runtime/make namespace object */
138
194
  /******/ (() => {
139
195
  /******/ // define __esModule on exports
@@ -145,6 +201,119 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
145
201
  /******/ };
146
202
  /******/ })();
147
203
  /******/
204
+ /******/ /* webpack/runtime/publicPath */
205
+ /******/ (() => {
206
+ /******/ var scriptUrl;
207
+ /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
208
+ /******/ var document = __webpack_require__.g.document;
209
+ /******/ if (!scriptUrl && document) {
210
+ /******/ if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
211
+ /******/ scriptUrl = document.currentScript.src;
212
+ /******/ if (!scriptUrl) {
213
+ /******/ var scripts = document.getElementsByTagName("script");
214
+ /******/ if(scripts.length) {
215
+ /******/ var i = scripts.length - 1;
216
+ /******/ while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src;
217
+ /******/ }
218
+ /******/ }
219
+ /******/ }
220
+ /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
221
+ /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
222
+ /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
223
+ /******/ scriptUrl = scriptUrl.replace(/^blob:/, "").replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
224
+ /******/ __webpack_require__.p = scriptUrl;
225
+ /******/ })();
226
+ /******/
227
+ /******/ /* webpack/runtime/jsonp chunk loading */
228
+ /******/ (() => {
229
+ /******/ // no baseURI
230
+ /******/
231
+ /******/ // object to store loaded and loading chunks
232
+ /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
233
+ /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
234
+ /******/ var installedChunks = {
235
+ /******/ "tsparticles.interaction.external.attract": 0
236
+ /******/ };
237
+ /******/
238
+ /******/ __webpack_require__.f.j = (chunkId, promises) => {
239
+ /******/ // JSONP chunk loading for javascript
240
+ /******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
241
+ /******/ if(installedChunkData !== 0) { // 0 means "already installed".
242
+ /******/
243
+ /******/ // a Promise means "currently loading".
244
+ /******/ if(installedChunkData) {
245
+ /******/ promises.push(installedChunkData[2]);
246
+ /******/ } else {
247
+ /******/ if(true) { // all chunks have JS
248
+ /******/ // setup Promise in chunk cache
249
+ /******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
250
+ /******/ promises.push(installedChunkData[2] = promise);
251
+ /******/
252
+ /******/ // start chunk loading
253
+ /******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
254
+ /******/ // create error before stack unwound to get useful stacktrace later
255
+ /******/ var error = new Error();
256
+ /******/ var loadingEnded = (event) => {
257
+ /******/ if(__webpack_require__.o(installedChunks, chunkId)) {
258
+ /******/ installedChunkData = installedChunks[chunkId];
259
+ /******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
260
+ /******/ if(installedChunkData) {
261
+ /******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
262
+ /******/ var realSrc = event && event.target && event.target.src;
263
+ /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
264
+ /******/ error.name = 'ChunkLoadError';
265
+ /******/ error.type = errorType;
266
+ /******/ error.request = realSrc;
267
+ /******/ installedChunkData[1](error);
268
+ /******/ }
269
+ /******/ }
270
+ /******/ };
271
+ /******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
272
+ /******/ }
273
+ /******/ }
274
+ /******/ }
275
+ /******/ };
276
+ /******/
277
+ /******/ // no prefetching
278
+ /******/
279
+ /******/ // no preloaded
280
+ /******/
281
+ /******/ // no HMR
282
+ /******/
283
+ /******/ // no HMR manifest
284
+ /******/
285
+ /******/ // no on chunks loaded
286
+ /******/
287
+ /******/ // install a JSONP callback for chunk loading
288
+ /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
289
+ /******/ var [chunkIds, moreModules, runtime] = data;
290
+ /******/ // add "moreModules" to the modules object,
291
+ /******/ // then flag all "chunkIds" as loaded and fire callback
292
+ /******/ var moduleId, chunkId, i = 0;
293
+ /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
294
+ /******/ for(moduleId in moreModules) {
295
+ /******/ if(__webpack_require__.o(moreModules, moduleId)) {
296
+ /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
297
+ /******/ }
298
+ /******/ }
299
+ /******/ if(runtime) var result = runtime(__webpack_require__);
300
+ /******/ }
301
+ /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
302
+ /******/ for(;i < chunkIds.length; i++) {
303
+ /******/ chunkId = chunkIds[i];
304
+ /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
305
+ /******/ installedChunks[chunkId][0]();
306
+ /******/ }
307
+ /******/ installedChunks[chunkId] = 0;
308
+ /******/ }
309
+ /******/
310
+ /******/ }
311
+ /******/
312
+ /******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_interaction_external_attract"] = this["webpackChunk_tsparticles_interaction_external_attract"] || [];
313
+ /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
314
+ /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
315
+ /******/ })();
316
+ /******/
148
317
  /************************************************************************/
149
318
  /******/
150
319
  /******/ // startup
@@ -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=>(()=>{var e={303:e=>{e.exports=t}},i={};function a(t){var n=i[t];if(void 0!==n)return n.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 n={};a.r(n),a.d(n,{Attract:()=>c,loadExternalAttractInteraction:()=>l});var o=a(303);function r(t,e,i,a,n,r){const c=e.actualOptions.interactivity.modes.attract;if(!c)return;const s=e.particles.quadTree.query(n,r);for(const e of s){const{dx:n,dy:r,distance:s}=(0,o.getDistances)(e.position,i),d=c.speed*c.factor,l=(0,o.clamp)(t.getEasing(c.easing)(1-s/a)*d,1,c.maxSpeed),p=o.Vector.create(s?n/s*l:d,s?r/s*l:d);e.position.subFrom(p)}}class c{constructor(){this.distance=200,this.duration=.4,this.easing=o.EasingType.easeOutQuad,this.factor=1,this.maxSpeed=50,this.speed=1}load(t){(0,o.isNull)(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 s="attract";class d extends o.ExternalInteractorBase{constructor(t,e){super(e),this._engine=t,e.attract||(e.attract={particles:[]}),this.handleClickMode=t=>{const i=this.container.actualOptions.interactivity.modes.attract;if(i&&t===s){e.attract||(e.attract={particles:[]}),e.attract.clicking=!0,e.attract.count=0;for(const t of e.attract.particles)this.isEnabled(t)&&t.velocity.setTo(t.initialVelocity);e.attract.particles=[],e.attract.finish=!1,setTimeout((()=>{e.destroyed||(e.attract||(e.attract={particles:[]}),e.attract.clicking=!1)}),i.duration*o.millisecondsToSeconds)}}}clear(){}init(){const t=this.container,e=t.actualOptions.interactivity.modes.attract;e&&(t.retina.attractModeDistance=e.distance*t.retina.pixelRatio)}interact(){const t=this.container,e=t.actualOptions,i=t.interactivity.status===o.mouseMoveEvent,a=e.interactivity.events,{enable:n,mode:c}=a.onHover,{enable:d,mode:l}=a.onClick;i&&n&&(0,o.isInArray)(s,c)?function(t,e,i){const a=e.interactivity.mouse.position,n=e.retina.attractModeDistance;!n||n<0||!a||r(t,e,a,n,new o.Circle(a.x,a.y,n),(t=>i(t)))}(this._engine,this.container,(t=>this.isEnabled(t))):d&&(0,o.isInArray)(s,l)&&function(t,e,i){e.attract||(e.attract={particles:[]});const{attract:a}=e;if(a.finish||(a.count||(a.count=0),a.count++,a.count===e.particles.count&&(a.finish=!0)),a.clicking){const a=e.interactivity.mouse.clickPosition,n=e.retina.attractModeDistance;if(!n||n<0||!a)return;r(t,e,a,n,new o.Circle(a.x,a.y,n),(t=>i(t)))}else!1===a.clicking&&(a.particles=[])}(this._engine,this.container,(t=>this.isEnabled(t)))}isEnabled(t){const e=this.container,i=e.actualOptions,a=e.interactivity.mouse,n=(t?.interactivity??i.interactivity).events;if(!(a.position&&n.onHover.enable||a.clickPosition&&n.onClick.enable))return!1;const r=n.onHover.mode,c=n.onClick.mode;return(0,o.isInArray)(s,r)||(0,o.isInArray)(s,c)}loadModeOptions(t,...e){t.attract||(t.attract=new c);for(const i of e)t.attract.load(i?.attract)}reset(){}}async function l(t,e=!0){t.checkVersion("3.9.1"),await t.addInteractor("externalAttract",(e=>Promise.resolve(new d(t,e))),e)}return n})()));
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var i in r)("object"==typeof exports?exports:e)[i]=r[i]}}(this,(e=>(()=>{var t,r,i={303(t){t.exports=e},773(e,t,r){r.d(t,{K:()=>a});var i=r(303);class a{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))}}}},a={};function o(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return i[e](r,r.exports,o),r.exports}o.m=i,o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce(((t,r)=>(o.f[r](e,t),t)),[])),o.u=e=>e+".min.js",o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},r="@tsparticles/interaction-external-attract:",o.l=(e,i,a,n)=>{if(t[e])t[e].push(i);else{var s,c;if(void 0!==a)for(var d=document.getElementsByTagName("script"),p=0;p<d.length;p++){var l=d[p];if(l.getAttribute("src")==e||l.getAttribute("data-webpack")==r+a){s=l;break}}s||(c=!0,(s=document.createElement("script")).charset="utf-8",o.nc&&s.setAttribute("nonce",o.nc),s.setAttribute("data-webpack",r+a),s.src=e),t[e]=[i];var u=(r,i)=>{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(i))),r)return r(i)},f=setTimeout(u.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=u.bind(null,s.onerror),s.onload=u.bind(null,s.onload),c&&document.head.appendChild(s)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;o.g.importScripts&&(e=o.g.location+"");var t=o.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var i=r.length-1;i>-1&&(!e||!/^http(s?):/.test(e));)e=r[i--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e})(),(()=>{var e={261:0};o.f.j=(t,r)=>{var i=o.o(e,t)?e[t]:void 0;if(0!==i)if(i)r.push(i[2]);else{var a=new Promise(((r,a)=>i=e[t]=[r,a]));r.push(i[2]=a);var n=o.p+o.u(t),s=new Error;o.l(n,(r=>{if(o.o(e,t)&&(0!==(i=e[t])&&(e[t]=void 0),i)){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,i[1](s)}}),"chunk-"+t,t)}};var t=(t,r)=>{var i,a,[n,s,c]=r,d=0;if(n.some((t=>0!==e[t]))){for(i in s)o.o(s,i)&&(o.m[i]=s[i]);if(c)c(o)}for(t&&t(r);d<n.length;d++)a=n[d],o.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={};o.r(n),o.d(n,{Attract:()=>s.K,loadExternalAttractInteraction:()=>c});var s=o(773);function c(e){e.checkVersion("4.0.0-alpha.1"),e.register((e=>{e.addInteractor("externalAttract",(async t=>{const{Attractor:r}=await o.e(62).then(o.bind(o,62));return new r(e,t)}))}))}return n})()));
@@ -1 +1 @@
1
- /*! tsParticles Attract External Interaction v3.9.1 by Matteo Bruni */
1
+ /*! tsParticles Attract External Interaction v4.0.0-alpha.1 by Matteo Bruni */
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { type Engine } from "@tsparticles/engine";
2
- export declare function loadExternalAttractInteraction(engine: Engine, refresh?: boolean): Promise<void>;
2
+ export declare function loadExternalAttractInteraction(engine: Engine): void;
3
3
  export * from "./Options/Classes/Attract.js";
4
- export * from "./Options/Interfaces/IAttract.js";
4
+ export type * from "./Options/Interfaces/IAttract.js";
package/umd/Attractor.js CHANGED
@@ -18,17 +18,13 @@
18
18
  constructor(engine, container) {
19
19
  super(container);
20
20
  this._engine = engine;
21
- if (!container.attract) {
22
- container.attract = { particles: [] };
23
- }
21
+ container.attract ??= { particles: [] };
24
22
  this.handleClickMode = (mode) => {
25
23
  const options = this.container.actualOptions, attract = options.interactivity.modes.attract;
26
24
  if (!attract || mode !== attractMode) {
27
25
  return;
28
26
  }
29
- if (!container.attract) {
30
- container.attract = { particles: [] };
31
- }
27
+ container.attract ??= { particles: [] };
32
28
  container.attract.clicking = true;
33
29
  container.attract.count = 0;
34
30
  for (const particle of container.attract.particles) {
@@ -43,9 +39,7 @@
43
39
  if (container.destroyed) {
44
40
  return;
45
41
  }
46
- if (!container.attract) {
47
- container.attract = { particles: [] };
48
- }
42
+ container.attract ??= { particles: [] };
49
43
  container.attract.clicking = false;
50
44
  }, attract.duration * engine_1.millisecondsToSeconds);
51
45
  };
@@ -77,9 +71,7 @@
77
71
  return (0, engine_1.isInArray)(attractMode, hoverMode) || (0, engine_1.isInArray)(attractMode, clickMode);
78
72
  }
79
73
  loadModeOptions(options, ...sources) {
80
- if (!options.attract) {
81
- options.attract = new Attract_js_1.Attract();
82
- }
74
+ options.attract ??= new Attract_js_1.Attract();
83
75
  for (const source of sources) {
84
76
  options.attract.load(source?.attract);
85
77
  }
package/umd/Utils.js CHANGED
@@ -25,14 +25,10 @@
25
25
  }
26
26
  }
27
27
  function clickAttract(engine, container, enabledCb) {
28
- if (!container.attract) {
29
- container.attract = { particles: [] };
30
- }
28
+ container.attract ??= { particles: [] };
31
29
  const { attract } = container;
32
30
  if (!attract.finish) {
33
- if (!attract.count) {
34
- attract.count = 0;
35
- }
31
+ attract.count ??= 0;
36
32
  attract.count++;
37
33
  if (attract.count === container.particles.count) {
38
34
  attract.finish = true;
package/umd/index.js CHANGED
@@ -9,6 +9,28 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
9
9
  if (k2 === undefined) k2 = k;
10
10
  o[k2] = m[k];
11
11
  }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || (function () {
18
+ var ownKeys = function(o) {
19
+ ownKeys = Object.getOwnPropertyNames || function (o) {
20
+ var ar = [];
21
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
22
+ return ar;
23
+ };
24
+ return ownKeys(o);
25
+ };
26
+ return function (mod) {
27
+ if (mod && mod.__esModule) return mod;
28
+ var result = {};
29
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
30
+ __setModuleDefault(result, mod);
31
+ return result;
32
+ };
33
+ })();
12
34
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
13
35
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
14
36
  };
@@ -18,19 +40,21 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
40
  if (v !== undefined) module.exports = v;
19
41
  }
20
42
  else if (typeof define === "function" && define.amd) {
21
- define(["require", "exports", "./Attractor.js", "./Options/Classes/Attract.js", "./Options/Interfaces/IAttract.js"], factory);
43
+ define(["require", "exports", "./Options/Classes/Attract.js"], factory);
22
44
  }
23
45
  })(function (require, exports) {
24
46
  "use strict";
47
+ var __syncRequire = typeof module === "object" && typeof module.exports === "object";
25
48
  Object.defineProperty(exports, "__esModule", { value: true });
26
49
  exports.loadExternalAttractInteraction = loadExternalAttractInteraction;
27
- const Attractor_js_1 = require("./Attractor.js");
28
- async function loadExternalAttractInteraction(engine, refresh = true) {
29
- engine.checkVersion("3.9.1");
30
- await engine.addInteractor("externalAttract", container => {
31
- return Promise.resolve(new Attractor_js_1.Attractor(engine, container));
32
- }, refresh);
50
+ function loadExternalAttractInteraction(engine) {
51
+ engine.checkVersion("4.0.0-alpha.1");
52
+ engine.register(e => {
53
+ e.addInteractor("externalAttract", async (container) => {
54
+ const { Attractor } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Attractor.js"))) : new Promise((resolve_1, reject_1) => { require(["./Attractor.js"], resolve_1, reject_1); }).then(__importStar));
55
+ return new Attractor(e, container);
56
+ });
57
+ });
33
58
  }
34
59
  __exportStar(require("./Options/Classes/Attract.js"), exports);
35
- __exportStar(require("./Options/Interfaces/IAttract.js"), exports);
36
60
  });