@tsparticles/interaction-external-bounce 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/Bouncer.js":
32
- /*!*********************************!*\
33
- !*** ./dist/browser/Bouncer.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 */ Bouncer: () => (/* binding */ Bouncer)\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_Bounce_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Options/Classes/Bounce.js */ \"./dist/browser/Options/Classes/Bounce.js\");\n\n\n\nconst bounceMode = \"bounce\";\nclass Bouncer extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ExternalInteractorBase {\n constructor(container) {\n super(container);\n }\n clear() {}\n init() {\n const container = this.container,\n bounce = container.actualOptions.interactivity.modes.bounce;\n if (!bounce) {\n return;\n }\n container.retina.bounceModeDistance = bounce.distance * container.retina.pixelRatio;\n }\n interact() {\n const container = this.container,\n options = container.actualOptions,\n events = options.interactivity.events,\n mouseMoveStatus = container.interactivity.status === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.mouseMoveEvent,\n hoverEnabled = events.onHover.enable,\n hoverMode = events.onHover.mode,\n divs = events.onDiv;\n if (mouseMoveStatus && hoverEnabled && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(bounceMode, hoverMode)) {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.mouseBounce)(this.container, p => this.isEnabled(p));\n } else {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.divBounce)(this.container, divs, bounceMode, 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 divs = events.onDiv;\n return !!mouse.position && events.onHover.enable && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(bounceMode, events.onHover.mode) || (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isDivModeEnabled)(bounceMode, divs);\n }\n loadModeOptions(options, ...sources) {\n if (!options.bounce) {\n options.bounce = new _Options_Classes_Bounce_js__WEBPACK_IMPORTED_MODULE_2__.Bounce();\n }\n for (const source of sources) {\n options.bounce.load(source?.bounce);\n }\n }\n reset() {}\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-external-bounce/./dist/browser/Bouncer.js?\n}");
38
-
39
- /***/ }),
40
-
41
- /***/ "./dist/browser/Options/Classes/Bounce.js":
31
+ /***/ "./dist/browser/Options/Classes/Bounce.js"
42
32
  /*!************************************************!*\
43
33
  !*** ./dist/browser/Options/Classes/Bounce.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 */ Bounce: () => (/* binding */ Bounce)\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 Bounce {\n constructor() {\n this.distance = 200;\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 }\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-external-bounce/./dist/browser/Options/Classes/Bounce.js?\n}");
37
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Bounce: () => (/* binding */ Bounce)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass Bounce {\n constructor() {\n this.distance = 200;\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 }\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-external-bounce/./dist/browser/Options/Classes/Bounce.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 */ divBounce: () => (/* binding */ divBounce),\n/* harmony export */ mouseBounce: () => (/* binding */ mouseBounce)\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 squareExp = 2,\n half = 0.5,\n halfPI = Math.PI * half,\n double = 2,\n toleranceFactor = 10,\n minRadius = 0;\nfunction processBounce(container, position, radius, area, enabledCb) {\n const query = container.particles.quadTree.query(area, enabledCb);\n for (const particle of query) {\n if (area instanceof _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Circle) {\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.circleBounce)((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.circleBounceDataFromParticle)(particle), {\n position,\n radius,\n mass: radius ** squareExp * halfPI,\n velocity: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin,\n factor: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin\n });\n } else if (area instanceof _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Rectangle) {\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.rectBounce)(particle, (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.calculateBounds)(position, radius));\n }\n }\n}\nfunction singleSelectorBounce(container, selector, div, bounceCb) {\n const query = document.querySelectorAll(selector);\n if (!query.length) {\n return;\n }\n query.forEach(item => {\n const elem = item,\n pxRatio = container.retina.pixelRatio,\n pos = {\n x: (elem.offsetLeft + elem.offsetWidth * half) * pxRatio,\n y: (elem.offsetTop + elem.offsetHeight * half) * pxRatio\n },\n radius = elem.offsetWidth * half * pxRatio,\n tolerance = toleranceFactor * pxRatio,\n area = div.type === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.DivType.circle ? new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Circle(pos.x, pos.y, radius + tolerance) : new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Rectangle(elem.offsetLeft * pxRatio - tolerance, elem.offsetTop * pxRatio - tolerance, elem.offsetWidth * pxRatio + tolerance * double, elem.offsetHeight * pxRatio + tolerance * double);\n bounceCb(pos, radius, area);\n });\n}\nfunction divBounce(container, divs, bounceMode, enabledCb) {\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.divModeExecute)(bounceMode, divs, (selector, div) => singleSelectorBounce(container, selector, div, (pos, radius, area) => processBounce(container, pos, radius, area, enabledCb)));\n}\nfunction mouseBounce(container, enabledCb) {\n const pxRatio = container.retina.pixelRatio,\n tolerance = toleranceFactor * pxRatio,\n mousePos = container.interactivity.mouse.position,\n radius = container.retina.bounceModeDistance;\n if (!radius || radius < minRadius || !mousePos) {\n return;\n }\n processBounce(container, mousePos, radius, new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Circle(mousePos.x, mousePos.y, radius + tolerance), enabledCb);\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-external-bounce/./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 */ Bounce: () => (/* reexport safe */ _Options_Classes_Bounce_js__WEBPACK_IMPORTED_MODULE_1__.Bounce),\n/* harmony export */ loadExternalBounceInteraction: () => (/* binding */ loadExternalBounceInteraction)\n/* harmony export */ });\n/* harmony import */ var _Bouncer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Bouncer.js */ \"./dist/browser/Bouncer.js\");\n/* harmony import */ var _Options_Classes_Bounce_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/Bounce.js */ \"./dist/browser/Options/Classes/Bounce.js\");\n\nasync function loadExternalBounceInteraction(engine, refresh = true) {\n engine.checkVersion(\"3.9.1\");\n await engine.addInteractor(\"externalBounce\", container => {\n return Promise.resolve(new _Bouncer_js__WEBPACK_IMPORTED_MODULE_0__.Bouncer(container));\n }, refresh);\n}\n\n\n\n//# sourceURL=webpack://@tsparticles/interaction-external-bounce/./dist/browser/index.js?\n}");
47
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Bounce: () => (/* reexport safe */ _Options_Classes_Bounce_js__WEBPACK_IMPORTED_MODULE_0__.Bounce),\n/* harmony export */ loadExternalBounceInteraction: () => (/* binding */ loadExternalBounceInteraction)\n/* harmony export */ });\n/* harmony import */ var _Options_Classes_Bounce_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Options/Classes/Bounce.js */ \"./dist/browser/Options/Classes/Bounce.js\");\nfunction loadExternalBounceInteraction(engine) {\n engine.checkVersion(\"4.0.0-alpha.1\");\n engine.register(e => {\n e.addInteractor(\"externalBounce\", async container => {\n const {\n Bouncer\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_Bouncer_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./Bouncer.js */ \"./dist/browser/Bouncer.js\"));\n return new Bouncer(container);\n });\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-external-bounce/./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-bounce:";
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.bounce": 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_bounce"] = this["webpackChunk_tsparticles_interaction_external_bounce"] || [];
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.bounce.min.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var n in o)("object"==typeof exports?exports:e)[n]=o[n]}}(this,(e=>(()=>{var t={303:t=>{t.exports=e}},o={};function n(e){var i=o[e];if(void 0!==i)return i.exports;var r=o[e]={exports:{}};return t[e](r,r.exports,n),r.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};n.r(i),n.d(i,{Bounce:()=>u,loadExternalBounceInteraction:()=>p});var r=n(303);const c=.5,s=Math.PI*c;function a(e,t,o,n,i){const c=e.particles.quadTree.query(n,i);for(const e of c)n instanceof r.Circle?(0,r.circleBounce)((0,r.circleBounceDataFromParticle)(e),{position:t,radius:o,mass:o**2*s,velocity:r.Vector.origin,factor:r.Vector.origin}):n instanceof r.Rectangle&&(0,r.rectBounce)(e,(0,r.calculateBounds)(t,o))}function l(e,t,o,n){(0,r.divModeExecute)(o,t,((t,o)=>function(e,t,o,n){const i=document.querySelectorAll(t);i.length&&i.forEach((t=>{const i=t,s=e.retina.pixelRatio,a={x:(i.offsetLeft+i.offsetWidth*c)*s,y:(i.offsetTop+i.offsetHeight*c)*s},l=i.offsetWidth*c*s,u=10*s,f=o.type===r.DivType.circle?new r.Circle(a.x,a.y,l+u):new r.Rectangle(i.offsetLeft*s-u,i.offsetTop*s-u,i.offsetWidth*s+2*u,i.offsetHeight*s+2*u);n(a,l,f)}))}(e,t,o,((t,o,i)=>a(e,t,o,i,n)))))}class u{constructor(){this.distance=200}load(e){(0,r.isNull)(e)||void 0!==e.distance&&(this.distance=e.distance)}}const f="bounce";class d extends r.ExternalInteractorBase{constructor(e){super(e)}clear(){}init(){const e=this.container,t=e.actualOptions.interactivity.modes.bounce;t&&(e.retina.bounceModeDistance=t.distance*e.retina.pixelRatio)}interact(){const e=this.container,t=e.actualOptions.interactivity.events,o=e.interactivity.status===r.mouseMoveEvent,n=t.onHover.enable,i=t.onHover.mode,c=t.onDiv;o&&n&&(0,r.isInArray)(f,i)?function(e,t){const o=10*e.retina.pixelRatio,n=e.interactivity.mouse.position,i=e.retina.bounceModeDistance;!i||i<0||!n||a(e,n,i,new r.Circle(n.x,n.y,i+o),t)}(this.container,(e=>this.isEnabled(e))):l(this.container,c,f,(e=>this.isEnabled(e)))}isEnabled(e){const t=this.container,o=t.actualOptions,n=t.interactivity.mouse,i=(e?.interactivity??o.interactivity).events,c=i.onDiv;return!!n.position&&i.onHover.enable&&(0,r.isInArray)(f,i.onHover.mode)||(0,r.isDivModeEnabled)(f,c)}loadModeOptions(e,...t){e.bounce||(e.bounce=new u);for(const o of t)e.bounce.load(o?.bounce)}reset(){}}async function p(e,t=!0){e.checkVersion("3.9.1"),await e.addInteractor("externalBounce",(e=>Promise.resolve(new d(e))),t)}return i})()));
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 n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,(e=>(()=>{var t,r,n={303(t){t.exports=e},786(e,t,r){r.d(t,{b:()=>o});var n=r(303);class o{constructor(){this.distance=200}load(e){(0,n.isNull)(e)||void 0!==e.distance&&(this.distance=e.distance)}}}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return n[e](r,r.exports,i),r.exports}i.m=n,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-bounce:",i.l=(e,n,o,a)=>{if(t[e])t[e].push(n);else{var c,s;if(void 0!==o)for(var l=document.getElementsByTagName("script"),u=0;u<l.length;u++){var p=l[u];if(p.getAttribute("src")==e||p.getAttribute("data-webpack")==r+o){c=p;break}}c||(s=!0,(c=document.createElement("script")).charset="utf-8",i.nc&&c.setAttribute("nonce",i.nc),c.setAttribute("data-webpack",r+o),c.src=e),t[e]=[n];var d=(r,n)=>{c.onerror=c.onload=null,clearTimeout(f);var o=t[e];if(delete t[e],c.parentNode&&c.parentNode.removeChild(c),o&&o.forEach((e=>e(n))),r)return r(n)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=d.bind(null,c.onerror),c.onload=d.bind(null,c.onload),s&&document.head.appendChild(c)}},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&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=e})(),(()=>{var e={186:0};i.f.j=(t,r)=>{var n=i.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var o=new Promise(((r,o)=>n=e[t]=[r,o]));r.push(n[2]=o);var a=i.p+i.u(t),c=new Error;i.l(a,(r=>{if(i.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var o=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;c.message="Loading chunk "+t+" failed.\n("+o+": "+a+")",c.name="ChunkLoadError",c.type=o,c.request=a,n[1](c)}}),"chunk-"+t,t)}};var t=(t,r)=>{var n,o,[a,c,s]=r,l=0;if(a.some((t=>0!==e[t]))){for(n in c)i.o(c,n)&&(i.m[n]=c[n]);if(s)s(i)}for(t&&t(r);l<a.length;l++)o=a[l],i.o(e,o)&&e[o]&&e[o][0](),e[o]=0},r=this.webpackChunk_tsparticles_interaction_external_bounce=this.webpackChunk_tsparticles_interaction_external_bounce||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var a={};i.r(a),i.d(a,{Bounce:()=>c.b,loadExternalBounceInteraction:()=>s});var c=i(786);function s(e){e.checkVersion("4.0.0-alpha.1"),e.register((e=>{e.addInteractor("externalBounce",(async e=>{const{Bouncer:t}=await i.e(85).then(i.bind(i,85));return new t(e)}))}))}return a})()));
@@ -1 +1 @@
1
- /*! tsParticles Bounce External Interaction v3.9.1 by Matteo Bruni */
1
+ /*! tsParticles Bounce External Interaction v4.0.0-alpha.1 by Matteo Bruni */
@@ -0,0 +1,5 @@
1
+ export interface IRectSideResult {
2
+ bounced: boolean;
3
+ position?: number;
4
+ velocity?: number;
5
+ }
package/types/Utils.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { type DivEvent, type Particle, type SingleOrMultiple } from "@tsparticles/engine";
1
+ import { type DivEvent, type IBounds, type Particle, type SingleOrMultiple } from "@tsparticles/engine";
2
2
  import type { BounceContainer } from "./Types.js";
3
3
  export declare function divBounce(container: BounceContainer, divs: SingleOrMultiple<DivEvent>, bounceMode: string, enabledCb: (p: Particle) => boolean): void;
4
4
  export declare function mouseBounce(container: BounceContainer, enabledCb: (p: Particle) => boolean): void;
5
+ export declare function rectBounce(particle: Particle, divBounds: IBounds): void;
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { type Engine } from "@tsparticles/engine";
2
- export declare function loadExternalBounceInteraction(engine: Engine, refresh?: boolean): Promise<void>;
2
+ export declare function loadExternalBounceInteraction(engine: Engine): void;
3
3
  export * from "./Options/Classes/Bounce.js";
4
- export * from "./Options/Interfaces/IBounce.js";
4
+ export type * from "./Options/Interfaces/IBounce.js";
package/umd/Bouncer.js CHANGED
@@ -42,9 +42,7 @@
42
42
  (0, engine_1.isDivModeEnabled)(bounceMode, divs));
43
43
  }
44
44
  loadModeOptions(options, ...sources) {
45
- if (!options.bounce) {
46
- options.bounce = new Bounce_js_1.Bounce();
47
- }
45
+ options.bounce ??= new Bounce_js_1.Bounce();
48
46
  for (const source of sources) {
49
47
  options.bounce.load(source?.bounce);
50
48
  }
@@ -0,0 +1,12 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ });
package/umd/Utils.js CHANGED
@@ -11,8 +11,9 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.divBounce = divBounce;
13
13
  exports.mouseBounce = mouseBounce;
14
+ exports.rectBounce = rectBounce;
14
15
  const engine_1 = require("@tsparticles/engine");
15
- const squareExp = 2, half = 0.5, halfPI = Math.PI * half, double = 2, toleranceFactor = 10, minRadius = 0;
16
+ const squareExp = 2, half = 0.5, halfPI = Math.PI * half, double = 2, toleranceFactor = 10, minRadius = 0, minVelocity = 0;
16
17
  function processBounce(container, position, radius, area, enabledCb) {
17
18
  const query = container.particles.quadTree.query(area, enabledCb);
18
19
  for (const particle of query) {
@@ -26,12 +27,12 @@
26
27
  });
27
28
  }
28
29
  else if (area instanceof engine_1.Rectangle) {
29
- (0, engine_1.rectBounce)(particle, (0, engine_1.calculateBounds)(position, radius));
30
+ rectBounce(particle, (0, engine_1.calculateBounds)(position, radius));
30
31
  }
31
32
  }
32
33
  }
33
34
  function singleSelectorBounce(container, selector, div, bounceCb) {
34
- const query = document.querySelectorAll(selector);
35
+ const query = (0, engine_1.safeDocument)().querySelectorAll(selector);
35
36
  if (!query.length) {
36
37
  return;
37
38
  }
@@ -46,7 +47,11 @@
46
47
  });
47
48
  }
48
49
  function divBounce(container, divs, bounceMode, enabledCb) {
49
- (0, engine_1.divModeExecute)(bounceMode, divs, (selector, div) => singleSelectorBounce(container, selector, div, (pos, radius, area) => processBounce(container, pos, radius, area, enabledCb)));
50
+ (0, engine_1.divModeExecute)(bounceMode, divs, (selector, div) => {
51
+ singleSelectorBounce(container, selector, div, (pos, radius, area) => {
52
+ processBounce(container, pos, radius, area, enabledCb);
53
+ });
54
+ });
50
55
  }
51
56
  function mouseBounce(container, enabledCb) {
52
57
  const pxRatio = container.retina.pixelRatio, tolerance = toleranceFactor * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
@@ -55,4 +60,77 @@
55
60
  }
56
61
  processBounce(container, mousePos, radius, new engine_1.Circle(mousePos.x, mousePos.y, radius + tolerance), enabledCb);
57
62
  }
63
+ function rectSideBounce(data) {
64
+ const res = { bounced: false }, { pSide, pOtherSide, rectSide, rectOtherSide, velocity, factor } = data;
65
+ if (pOtherSide.min < rectOtherSide.min ||
66
+ pOtherSide.min > rectOtherSide.max ||
67
+ pOtherSide.max < rectOtherSide.min ||
68
+ pOtherSide.max > rectOtherSide.max) {
69
+ return res;
70
+ }
71
+ if ((pSide.max >= rectSide.min && pSide.max <= (rectSide.max + rectSide.min) * half && velocity > minVelocity) ||
72
+ (pSide.min <= rectSide.max && pSide.min > (rectSide.max + rectSide.min) * half && velocity < minVelocity)) {
73
+ res.velocity = velocity * -factor;
74
+ res.bounced = true;
75
+ }
76
+ return res;
77
+ }
78
+ function rectBounce(particle, divBounds) {
79
+ const pPos = particle.getPosition(), size = particle.getRadius(), bounds = (0, engine_1.calculateBounds)(pPos, size), bounceOptions = particle.options.bounce, resH = rectSideBounce({
80
+ pSide: {
81
+ min: bounds.left,
82
+ max: bounds.right,
83
+ },
84
+ pOtherSide: {
85
+ min: bounds.top,
86
+ max: bounds.bottom,
87
+ },
88
+ rectSide: {
89
+ min: divBounds.left,
90
+ max: divBounds.right,
91
+ },
92
+ rectOtherSide: {
93
+ min: divBounds.top,
94
+ max: divBounds.bottom,
95
+ },
96
+ velocity: particle.velocity.x,
97
+ factor: (0, engine_1.getRangeValue)(bounceOptions.horizontal.value),
98
+ });
99
+ if (resH.bounced) {
100
+ if (resH.velocity !== undefined) {
101
+ particle.velocity.x = resH.velocity;
102
+ }
103
+ if (resH.position !== undefined) {
104
+ particle.position.x = resH.position;
105
+ }
106
+ }
107
+ const resV = rectSideBounce({
108
+ pSide: {
109
+ min: bounds.top,
110
+ max: bounds.bottom,
111
+ },
112
+ pOtherSide: {
113
+ min: bounds.left,
114
+ max: bounds.right,
115
+ },
116
+ rectSide: {
117
+ min: divBounds.top,
118
+ max: divBounds.bottom,
119
+ },
120
+ rectOtherSide: {
121
+ min: divBounds.left,
122
+ max: divBounds.right,
123
+ },
124
+ velocity: particle.velocity.y,
125
+ factor: (0, engine_1.getRangeValue)(bounceOptions.vertical.value),
126
+ });
127
+ if (resV.bounced) {
128
+ if (resV.velocity !== undefined) {
129
+ particle.velocity.y = resV.velocity;
130
+ }
131
+ if (resV.position !== undefined) {
132
+ particle.position.y = resV.position;
133
+ }
134
+ }
135
+ }
58
136
  });
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", "./Bouncer.js", "./Options/Classes/Bounce.js", "./Options/Interfaces/IBounce.js"], factory);
43
+ define(["require", "exports", "./Options/Classes/Bounce.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.loadExternalBounceInteraction = loadExternalBounceInteraction;
27
- const Bouncer_js_1 = require("./Bouncer.js");
28
- async function loadExternalBounceInteraction(engine, refresh = true) {
29
- engine.checkVersion("3.9.1");
30
- await engine.addInteractor("externalBounce", container => {
31
- return Promise.resolve(new Bouncer_js_1.Bouncer(container));
32
- }, refresh);
50
+ function loadExternalBounceInteraction(engine) {
51
+ engine.checkVersion("4.0.0-alpha.1");
52
+ engine.register(e => {
53
+ e.addInteractor("externalBounce", async (container) => {
54
+ const { Bouncer } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Bouncer.js"))) : new Promise((resolve_1, reject_1) => { require(["./Bouncer.js"], resolve_1, reject_1); }).then(__importStar));
55
+ return new Bouncer(container);
56
+ });
57
+ });
33
58
  }
34
59
  __exportStar(require("./Options/Classes/Bounce.js"), exports);
35
- __exportStar(require("./Options/Interfaces/IBounce.js"), exports);
36
60
  });