@tsparticles/interaction-external-bounce 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/Bounce.js":
32
+ /*!************************************************!*\
33
+ !*** ./dist/browser/Options/Classes/Bounce.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 */ Bounce: () => (/* binding */ Bounce)\n/* harmony export */ });\nclass Bounce {\n constructor() {\n this.distance = 200;\n }\n load(data) {\n if (!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?");
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 */ 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\");\nasync function loadExternalBounceInteraction(engine, refresh = true) {\n await engine.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 }, refresh);\n}\n\n\n\n//# sourceURL=webpack://@tsparticles/interaction-external-bounce/./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-bounce:";
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,146 +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.bounce": 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_bounce"] = this["webpackChunk_tsparticles_interaction_external_bounce"] || [];
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
- Bounce: () => (/* reexport */ Bounce),
95
- loadExternalBounceInteraction: () => (/* binding */ loadExternalBounceInteraction)
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/Bounce.js
101
- class Bounce {
102
- constructor() {
103
- this.distance = 200;
104
- }
105
- load(data) {
106
- if (!data) {
107
- return;
108
- }
109
- if (data.distance !== undefined) {
110
- this.distance = data.distance;
111
- }
112
- }
113
- }
114
- ;// CONCATENATED MODULE: ./dist/browser/Bouncer.js
115
-
116
-
117
- const bounceMode = "bounce",
118
- squareExp = 2,
119
- Bouncer_double = 2,
120
- half = 0.5,
121
- halfPI = Math.PI * half,
122
- toleranceFactor = 10,
123
- minRadius = 0;
124
- class Bouncer extends engine_root_window_.ExternalInteractorBase {
125
- constructor(container) {
126
- super(container);
127
- this._processBounce = (position, radius, area) => {
128
- const query = this.container.particles.quadTree.query(area, p => this.isEnabled(p));
129
- for (const particle of query) {
130
- if (area instanceof engine_root_window_.Circle) {
131
- (0,engine_root_window_.circleBounce)((0,engine_root_window_.circleBounceDataFromParticle)(particle), {
132
- position,
133
- radius,
134
- mass: radius ** squareExp * halfPI,
135
- velocity: engine_root_window_.Vector.origin,
136
- factor: engine_root_window_.Vector.origin
137
- });
138
- } else if (area instanceof engine_root_window_.Rectangle) {
139
- (0,engine_root_window_.rectBounce)(particle, (0,engine_root_window_.calculateBounds)(position, radius));
140
- }
141
- }
142
- };
143
- this._processMouseBounce = () => {
144
- const container = this.container,
145
- pxRatio = container.retina.pixelRatio,
146
- tolerance = toleranceFactor * pxRatio,
147
- mousePos = container.interactivity.mouse.position,
148
- radius = container.retina.bounceModeDistance;
149
- if (!radius || radius < minRadius || !mousePos) {
150
- return;
151
- }
152
- this._processBounce(mousePos, radius, new engine_root_window_.Circle(mousePos.x, mousePos.y, radius + tolerance));
153
- };
154
- this._singleSelectorBounce = (selector, div) => {
155
- const container = this.container,
156
- query = document.querySelectorAll(selector);
157
- if (!query.length) {
158
- return;
159
- }
160
- query.forEach(item => {
161
- const elem = item,
162
- pxRatio = container.retina.pixelRatio,
163
- pos = {
164
- x: (elem.offsetLeft + elem.offsetWidth * half) * pxRatio,
165
- y: (elem.offsetTop + elem.offsetHeight * half) * pxRatio
166
- },
167
- radius = elem.offsetWidth * half * pxRatio,
168
- tolerance = toleranceFactor * pxRatio,
169
- area = div.type === "circle" ? new engine_root_window_.Circle(pos.x, pos.y, radius + tolerance) : new engine_root_window_.Rectangle(elem.offsetLeft * pxRatio - tolerance, elem.offsetTop * pxRatio - tolerance, elem.offsetWidth * pxRatio + tolerance * Bouncer_double, elem.offsetHeight * pxRatio + tolerance * Bouncer_double);
170
- this._processBounce(pos, radius, area);
171
- });
172
- };
173
- }
174
- clear() {}
175
- init() {
176
- const container = this.container,
177
- bounce = container.actualOptions.interactivity.modes.bounce;
178
- if (!bounce) {
179
- return;
180
- }
181
- container.retina.bounceModeDistance = bounce.distance * container.retina.pixelRatio;
182
- }
183
- async interact() {
184
- const container = this.container,
185
- options = container.actualOptions,
186
- events = options.interactivity.events,
187
- mouseMoveStatus = container.interactivity.status === engine_root_window_.mouseMoveEvent,
188
- hoverEnabled = events.onHover.enable,
189
- hoverMode = events.onHover.mode,
190
- divs = events.onDiv;
191
- if (mouseMoveStatus && hoverEnabled && (0,engine_root_window_.isInArray)(bounceMode, hoverMode)) {
192
- this._processMouseBounce();
193
- } else {
194
- (0,engine_root_window_.divModeExecute)(bounceMode, divs, (selector, div) => this._singleSelectorBounce(selector, div));
195
- }
196
- await Promise.resolve();
197
- }
198
- isEnabled(particle) {
199
- const container = this.container,
200
- options = container.actualOptions,
201
- mouse = container.interactivity.mouse,
202
- events = (particle?.interactivity ?? options.interactivity).events,
203
- divs = events.onDiv;
204
- return !!mouse.position && events.onHover.enable && (0,engine_root_window_.isInArray)(bounceMode, events.onHover.mode) || (0,engine_root_window_.isDivModeEnabled)(bounceMode, divs);
205
- }
206
- loadModeOptions(options, ...sources) {
207
- if (!options.bounce) {
208
- options.bounce = new Bounce();
209
- }
210
- for (const source of sources) {
211
- options.bounce.load(source?.bounce);
212
- }
213
- }
214
- reset() {}
215
- }
216
- ;// CONCATENATED MODULE: ./dist/browser/index.js
217
-
218
- async function loadExternalBounceInteraction(engine, refresh = true) {
219
- await engine.addInteractor("externalBounce", container => new Bouncer(container), refresh);
220
- }
221
-
222
-
223
- })();
224
-
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
+ /******/
225
333
  /******/ return __webpack_exports__;
226
334
  /******/ })()
227
335
  ;
@@ -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=>(()=>{"use strict";var t={533: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={};return(()=>{n.r(i),n.d(i,{Bounce:()=>t,loadExternalBounceInteraction:()=>a});var e=n(533);class t{constructor(){this.distance=200}load(e){e&&void 0!==e.distance&&(this.distance=e.distance)}}const o="bounce",r=.5,s=Math.PI*r;class c extends e.ExternalInteractorBase{constructor(t){super(t),this._processBounce=(t,o,n)=>{const i=this.container.particles.quadTree.query(n,(e=>this.isEnabled(e)));for(const r of i)n instanceof e.Circle?(0,e.circleBounce)((0,e.circleBounceDataFromParticle)(r),{position:t,radius:o,mass:o**2*s,velocity:e.Vector.origin,factor:e.Vector.origin}):n instanceof e.Rectangle&&(0,e.rectBounce)(r,(0,e.calculateBounds)(t,o))},this._processMouseBounce=()=>{const t=this.container,o=10*t.retina.pixelRatio,n=t.interactivity.mouse.position,i=t.retina.bounceModeDistance;!i||i<0||!n||this._processBounce(n,i,new e.Circle(n.x,n.y,i+o))},this._singleSelectorBounce=(t,o)=>{const n=this.container,i=document.querySelectorAll(t);i.length&&i.forEach((t=>{const i=t,s=n.retina.pixelRatio,c={x:(i.offsetLeft+i.offsetWidth*r)*s,y:(i.offsetTop+i.offsetHeight*r)*s},a=i.offsetWidth*r*s,l=10*s,u="circle"===o.type?new e.Circle(c.x,c.y,a+l):new e.Rectangle(i.offsetLeft*s-l,i.offsetTop*s-l,i.offsetWidth*s+2*l,i.offsetHeight*s+2*l);this._processBounce(c,a,u)}))}}clear(){}init(){const e=this.container,t=e.actualOptions.interactivity.modes.bounce;t&&(e.retina.bounceModeDistance=t.distance*e.retina.pixelRatio)}async interact(){const t=this.container,n=t.actualOptions.interactivity.events,i=t.interactivity.status===e.mouseMoveEvent,r=n.onHover.enable,s=n.onHover.mode,c=n.onDiv;i&&r&&(0,e.isInArray)(o,s)?this._processMouseBounce():(0,e.divModeExecute)(o,c,((e,t)=>this._singleSelectorBounce(e,t))),await Promise.resolve()}isEnabled(t){const n=this.container,i=n.actualOptions,r=n.interactivity.mouse,s=(t?.interactivity??i.interactivity).events,c=s.onDiv;return!!r.position&&s.onHover.enable&&(0,e.isInArray)(o,s.onHover.mode)||(0,e.isDivModeEnabled)(o,c)}loadModeOptions(e,...o){e.bounce||(e.bounce=new t);for(const t of o)e.bounce.load(t?.bounce)}reset(){}}async function a(e,t=!0){await e.addInteractor("externalBounce",(e=>new c(e)),t)}})(),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={523:(e,t,r)=>{r.d(t,{s:()=>n});class n{constructor(){this.distance=200}load(e){e&&void 0!==e.distance&&(this.distance=e.distance)}}},533:t=>{t.exports=e}},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.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-bounce:",i.l=(e,n,o,a)=>{if(t[e])t[e].push(n);else{var c,s;if(void 0!==o)for(var u=document.getElementsByTagName("script"),l=0;l<u.length;l++){var d=u[l];if(d.getAttribute("src")==e||d.getAttribute("data-webpack")==r+o){c=d;break}}c||(s=!0,(c=document.createElement("script")).charset="utf-8",c.timeout=120,i.nc&&c.setAttribute("nonce",i.nc),c.setAttribute("data-webpack",r+o),c.src=e),t[e]=[n];var p=(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(p.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=p.bind(null,c.onerror),c.onload=p.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&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&!e;)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=e})(),(()=>{var e={251: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=r[0],c=r[1],s=r[2],u=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);u<a.length;u++)o=a[u],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={};return(()=>{i.r(a),i.d(a,{Bounce:()=>e.s,loadExternalBounceInteraction:()=>t});var e=i(523);async function t(e,t=!0){await e.addInteractor("externalBounce",(async e=>{const{Bouncer:t}=await i.e(33).then(i.bind(i,33));return new t(e)}),t)}})(),a})()));
@@ -1 +1 @@
1
- /*! tsParticles Bounce External Interaction v3.1.0 by Matteo Bruni */
1
+ /*! tsParticles Bounce External Interaction v3.2.0 by Matteo Bruni */
@@ -8,7 +8,4 @@ export declare class Bouncer extends ExternalInteractorBase<BounceContainer> {
8
8
  isEnabled(particle?: Particle): boolean;
9
9
  loadModeOptions(options: Modes & BounceMode, ...sources: RecursivePartial<(IModes & IBounceMode) | undefined>[]): void;
10
10
  reset(): void;
11
- private readonly _processBounce;
12
- private readonly _processMouseBounce;
13
- private readonly _singleSelectorBounce;
14
11
  }
@@ -0,0 +1,4 @@
1
+ import { type DivEvent, type Particle, type SingleOrMultiple } from "@tsparticles/engine";
2
+ import type { BounceContainer } from "./Types.js";
3
+ export declare function divBounce(container: BounceContainer, divs: SingleOrMultiple<DivEvent>, bounceMode: string, enabledCb: (p: Particle) => boolean): void;
4
+ export declare function mouseBounce(container: BounceContainer, enabledCb: (p: Particle) => boolean): void;
package/umd/Bouncer.js CHANGED
@@ -1,3 +1,26 @@
1
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
+ if (k2 === undefined) k2 = k;
3
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
+ desc = { enumerable: true, get: function() { return m[k]; } };
6
+ }
7
+ Object.defineProperty(o, k2, desc);
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
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 (mod) {
18
+ if (mod && mod.__esModule) return mod;
19
+ var result = {};
20
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21
+ __setModuleDefault(result, mod);
22
+ return result;
23
+ };
1
24
  (function (factory) {
2
25
  if (typeof module === "object" && typeof module.exports === "object") {
3
26
  var v = factory(require, exports);
@@ -8,53 +31,15 @@
8
31
  }
9
32
  })(function (require, exports) {
10
33
  "use strict";
34
+ var __syncRequire = typeof module === "object" && typeof module.exports === "object";
11
35
  Object.defineProperty(exports, "__esModule", { value: true });
12
36
  exports.Bouncer = void 0;
13
37
  const engine_1 = require("@tsparticles/engine");
14
38
  const Bounce_js_1 = require("./Options/Classes/Bounce.js");
15
- const bounceMode = "bounce", squareExp = 2, double = 2, half = 0.5, halfPI = Math.PI * half, toleranceFactor = 10, minRadius = 0;
39
+ const bounceMode = "bounce";
16
40
  class Bouncer extends engine_1.ExternalInteractorBase {
17
41
  constructor(container) {
18
42
  super(container);
19
- this._processBounce = (position, radius, area) => {
20
- const query = this.container.particles.quadTree.query(area, (p) => this.isEnabled(p));
21
- for (const particle of query) {
22
- if (area instanceof engine_1.Circle) {
23
- (0, engine_1.circleBounce)((0, engine_1.circleBounceDataFromParticle)(particle), {
24
- position,
25
- radius,
26
- mass: radius ** squareExp * halfPI,
27
- velocity: engine_1.Vector.origin,
28
- factor: engine_1.Vector.origin,
29
- });
30
- }
31
- else if (area instanceof engine_1.Rectangle) {
32
- (0, engine_1.rectBounce)(particle, (0, engine_1.calculateBounds)(position, radius));
33
- }
34
- }
35
- };
36
- this._processMouseBounce = () => {
37
- const container = this.container, pxRatio = container.retina.pixelRatio, tolerance = toleranceFactor * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
38
- if (!radius || radius < minRadius || !mousePos) {
39
- return;
40
- }
41
- this._processBounce(mousePos, radius, new engine_1.Circle(mousePos.x, mousePos.y, radius + tolerance));
42
- };
43
- this._singleSelectorBounce = (selector, div) => {
44
- const container = this.container, query = document.querySelectorAll(selector);
45
- if (!query.length) {
46
- return;
47
- }
48
- query.forEach((item) => {
49
- const elem = item, pxRatio = container.retina.pixelRatio, pos = {
50
- x: (elem.offsetLeft + elem.offsetWidth * half) * pxRatio,
51
- y: (elem.offsetTop + elem.offsetHeight * half) * pxRatio,
52
- }, radius = elem.offsetWidth * half * pxRatio, tolerance = toleranceFactor * pxRatio, area = div.type === "circle"
53
- ? new engine_1.Circle(pos.x, pos.y, radius + tolerance)
54
- : new engine_1.Rectangle(elem.offsetLeft * pxRatio - tolerance, elem.offsetTop * pxRatio - tolerance, elem.offsetWidth * pxRatio + tolerance * double, elem.offsetHeight * pxRatio + tolerance * double);
55
- this._processBounce(pos, radius, area);
56
- });
57
- };
58
43
  }
59
44
  clear() {
60
45
  }
@@ -68,12 +53,13 @@
68
53
  async interact() {
69
54
  const container = this.container, options = container.actualOptions, events = options.interactivity.events, mouseMoveStatus = container.interactivity.status === engine_1.mouseMoveEvent, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv;
70
55
  if (mouseMoveStatus && hoverEnabled && (0, engine_1.isInArray)(bounceMode, hoverMode)) {
71
- this._processMouseBounce();
56
+ const { mouseBounce } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Utils.js"))) : new Promise((resolve_1, reject_1) => { require(["./Utils.js"], resolve_1, reject_1); }).then(__importStar));
57
+ mouseBounce(this.container, (p) => this.isEnabled(p));
72
58
  }
73
59
  else {
74
- (0, engine_1.divModeExecute)(bounceMode, divs, (selector, div) => this._singleSelectorBounce(selector, div));
60
+ const { divBounce } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Utils.js"))) : new Promise((resolve_2, reject_2) => { require(["./Utils.js"], resolve_2, reject_2); }).then(__importStar));
61
+ divBounce(this.container, divs, bounceMode, (p) => this.isEnabled(p));
75
62
  }
76
- await Promise.resolve();
77
63
  }
78
64
  isEnabled(particle) {
79
65
  const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? options.interactivity).events, divs = events.onDiv;
package/umd/Utils.js ADDED
@@ -0,0 +1,59 @@
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", "@tsparticles/engine"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.mouseBounce = exports.divBounce = void 0;
13
+ const engine_1 = require("@tsparticles/engine");
14
+ const squareExp = 2, half = 0.5, halfPI = Math.PI * half, double = 2, toleranceFactor = 10, minRadius = 0;
15
+ function processBounce(container, position, radius, area, enabledCb) {
16
+ const query = container.particles.quadTree.query(area, enabledCb);
17
+ for (const particle of query) {
18
+ if (area instanceof engine_1.Circle) {
19
+ (0, engine_1.circleBounce)((0, engine_1.circleBounceDataFromParticle)(particle), {
20
+ position,
21
+ radius,
22
+ mass: radius ** squareExp * halfPI,
23
+ velocity: engine_1.Vector.origin,
24
+ factor: engine_1.Vector.origin,
25
+ });
26
+ }
27
+ else if (area instanceof engine_1.Rectangle) {
28
+ (0, engine_1.rectBounce)(particle, (0, engine_1.calculateBounds)(position, radius));
29
+ }
30
+ }
31
+ }
32
+ function singleSelectorBounce(container, selector, div, bounceCb) {
33
+ const query = document.querySelectorAll(selector);
34
+ if (!query.length) {
35
+ return;
36
+ }
37
+ query.forEach((item) => {
38
+ const elem = item, pxRatio = container.retina.pixelRatio, pos = {
39
+ x: (elem.offsetLeft + elem.offsetWidth * half) * pxRatio,
40
+ y: (elem.offsetTop + elem.offsetHeight * half) * pxRatio,
41
+ }, radius = elem.offsetWidth * half * pxRatio, tolerance = toleranceFactor * pxRatio, area = div.type === "circle"
42
+ ? new engine_1.Circle(pos.x, pos.y, radius + tolerance)
43
+ : new engine_1.Rectangle(elem.offsetLeft * pxRatio - tolerance, elem.offsetTop * pxRatio - tolerance, elem.offsetWidth * pxRatio + tolerance * double, elem.offsetHeight * pxRatio + tolerance * double);
44
+ bounceCb(pos, radius, area);
45
+ });
46
+ }
47
+ function divBounce(container, divs, bounceMode, enabledCb) {
48
+ (0, engine_1.divModeExecute)(bounceMode, divs, (selector, div) => singleSelectorBounce(container, selector, div, (pos, radius, area) => processBounce(container, pos, radius, area, enabledCb)));
49
+ }
50
+ exports.divBounce = divBounce;
51
+ function mouseBounce(container, enabledCb) {
52
+ const pxRatio = container.retina.pixelRatio, tolerance = toleranceFactor * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
53
+ if (!radius || radius < minRadius || !mousePos) {
54
+ return;
55
+ }
56
+ processBounce(container, mousePos, radius, new engine_1.Circle(mousePos.x, mousePos.y, radius + tolerance), enabledCb);
57
+ }
58
+ exports.mouseBounce = mouseBounce;
59
+ });