@tsparticles/interaction-external-bounce 4.0.0-alpha.3 → 4.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/820.min.js +2 -0
- package/820.min.js.LICENSE.txt +1 -0
- package/browser/Bouncer.js +17 -8
- package/browser/Utils.js +5 -4
- package/browser/index.js +5 -3
- package/cjs/Bouncer.js +17 -8
- package/cjs/Utils.js +5 -4
- package/cjs/index.js +5 -3
- package/dist_browser_Bouncer_js.js +3 -3
- package/esm/Bouncer.js +17 -8
- package/esm/Utils.js +5 -4
- package/esm/index.js +5 -3
- package/package.json +3 -2
- package/report.html +1 -1
- package/tsparticles.interaction.external.bounce.js +48 -20
- package/tsparticles.interaction.external.bounce.min.js +1 -1
- package/tsparticles.interaction.external.bounce.min.js.LICENSE.txt +1 -1
- package/types/Bouncer.d.ts +4 -3
- package/types/Options/Classes/BounceOptions.d.ts +3 -3
- package/types/Types.d.ts +2 -2
- package/types/Utils.d.ts +3 -2
- package/umd/Bouncer.js +19 -10
- package/umd/Utils.js +12 -11
- package/umd/index.js +6 -4
- package/85.min.js +0 -2
- package/85.min.js.LICENSE.txt +0 -1
package/820.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 820.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_interaction_external_bounce=this.webpackChunk_tsparticles_interaction_external_bounce||[]).push([[820],{820(t,e,i){i.d(e,{Bouncer:()=>d});var o=i(702),n=i(303);const c=Math.PI*n.half;function a(t,e,i,o,a){const r=t.particles.quadTree.query(o,a);for(const t of r)o instanceof n.Circle?(0,n.circleBounce)((0,n.circleBounceDataFromParticle)(t),{position:e,radius:i,mass:i**2*c,velocity:n.Vector.origin,factor:n.Vector.origin}):o instanceof n.Rectangle&&l(t,(0,n.calculateBounds)(e,i))}function r(t,e,i,c){(0,o.divModeExecute)(i,e,((e,i)=>{!function(t,e,i,c){const a=(0,n.safeDocument)().querySelectorAll(e);a.length&&a.forEach((e=>{const a=e,r=t.retina.pixelRatio,s={x:(a.offsetLeft+a.offsetWidth*n.half)*r,y:(a.offsetTop+a.offsetHeight*n.half)*r},l=a.offsetWidth*n.half*r,u=10*r,f=i.type===o.DivType.circle?new n.Circle(s.x,s.y,l+u):new n.Rectangle(a.offsetLeft*r-u,a.offsetTop*r-u,a.offsetWidth*r+u*n.double,a.offsetHeight*r+u*n.double);c(s,l,f)}))}(t,e,i,((e,i,o)=>{a(t,e,i,o,c)}))}))}function s(t){const e={bounced:!1},{pSide:i,pOtherSide:o,rectSide:c,rectOtherSide:a,velocity:r,factor:s}=t;return o.min<a.min||o.min>a.max||o.max<a.min||o.max>a.max||(i.max>=c.min&&i.max<=(c.max+c.min)*n.half&&r>0||i.min<=c.max&&i.min>(c.max+c.min)*n.half&&r<0)&&(e.velocity=r*-s,e.bounced=!0),e}function l(t,e){const i=t.getPosition(),o=t.getRadius(),c=(0,n.calculateBounds)(i,o),a=t.options.bounce,r=s({pSide:{min:c.left,max:c.right},pOtherSide:{min:c.top,max:c.bottom},rectSide:{min:e.left,max:e.right},rectOtherSide:{min:e.top,max:e.bottom},velocity:t.velocity.x,factor:(0,n.getRangeValue)(a.horizontal.value)});r.bounced&&(void 0!==r.velocity&&(t.velocity.x=r.velocity),void 0!==r.position&&(t.position.x=r.position));const l=s({pSide:{min:c.top,max:c.bottom},pOtherSide:{min:c.left,max:c.right},rectSide:{min:e.top,max:e.bottom},rectOtherSide:{min:e.left,max:e.right},velocity:t.velocity.y,factor:(0,n.getRangeValue)(a.vertical.value)});l.bounced&&(void 0!==l.velocity&&(t.velocity.y=l.velocity),void 0!==l.position&&(t.position.y=l.position))}var u=i(405);const f="bounce";class d extends o.ExternalInteractorBase{constructor(t){super(t)}clear(){}init(){const t=this.container,e=t.actualOptions.interactivity?.modes.bounce;e&&(t.retina.bounceModeDistance=e.distance*t.retina.pixelRatio)}interact(t){const e=this.container.actualOptions,i=e.interactivity?.events,c=t.status===o.mouseMoveEvent;if(!i)return;const s=i.onHover.enable,l=i.onHover.mode,u=i.onDiv;c&&s&&(0,n.isInArray)(f,l)?function(t,e,i){const o=10*t.retina.pixelRatio,c=e.mouse.position,r=t.retina.bounceModeDistance;!r||r<0||!c||a(t,c,r,new n.Circle(c.x,c.y,r+o),i)}(this.container,t,(e=>this.isEnabled(t,e))):r(this.container,u,f,(e=>this.isEnabled(t,e)))}isEnabled(t,e){const i=this.container.actualOptions,c=t.mouse,a=(e?.interactivity??i.interactivity)?.events;if(!a)return!1;const r=a.onDiv;return!!c.position&&a.onHover.enable&&(0,n.isInArray)(f,a.onHover.mode)||(0,o.isDivModeEnabled)(f,r)}loadModeOptions(t,...e){t.bounce??=new u.b;for(const i of e)t.bounce.load(i?.bounce)}reset(){}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Bounce External Interaction v4.0.0-alpha.4 by Matteo Bruni */
|
package/browser/Bouncer.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ExternalInteractorBase, isDivModeEnabled,
|
|
1
|
+
import { ExternalInteractorBase, isDivModeEnabled, mouseMoveEvent, } from "@tsparticles/plugin-interactivity";
|
|
2
|
+
import { isInArray } from "@tsparticles/engine";
|
|
2
3
|
import { divBounce, mouseBounce } from "./Utils.js";
|
|
3
4
|
import { Bounce } from "./Options/Classes/Bounce.js";
|
|
4
5
|
const bounceMode = "bounce";
|
|
@@ -9,23 +10,31 @@ export class Bouncer extends ExternalInteractorBase {
|
|
|
9
10
|
clear() {
|
|
10
11
|
}
|
|
11
12
|
init() {
|
|
12
|
-
const container = this.container, bounce = container.actualOptions.interactivity
|
|
13
|
+
const container = this.container, bounce = container.actualOptions.interactivity?.modes.bounce;
|
|
13
14
|
if (!bounce) {
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
17
|
container.retina.bounceModeDistance = bounce.distance * container.retina.pixelRatio;
|
|
17
18
|
}
|
|
18
|
-
interact() {
|
|
19
|
-
const container = this.container, options = container.actualOptions, events = options.interactivity
|
|
19
|
+
interact(interactivityData) {
|
|
20
|
+
const container = this.container, options = container.actualOptions, events = options.interactivity?.events, mouseMoveStatus = interactivityData.status === mouseMoveEvent;
|
|
21
|
+
if (!events) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv;
|
|
20
25
|
if (mouseMoveStatus && hoverEnabled && isInArray(bounceMode, hoverMode)) {
|
|
21
|
-
mouseBounce(this.container, p => this.isEnabled(p));
|
|
26
|
+
mouseBounce(this.container, interactivityData, p => this.isEnabled(interactivityData, p));
|
|
22
27
|
}
|
|
23
28
|
else {
|
|
24
|
-
divBounce(this.container, divs, bounceMode, p => this.isEnabled(p));
|
|
29
|
+
divBounce(this.container, divs, bounceMode, p => this.isEnabled(interactivityData, p));
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
|
-
isEnabled(particle) {
|
|
28
|
-
const container = this.container, options = container.actualOptions, mouse =
|
|
32
|
+
isEnabled(interactivityData, particle) {
|
|
33
|
+
const container = this.container, options = container.actualOptions, mouse = interactivityData.mouse, events = (particle?.interactivity ?? options.interactivity)?.events;
|
|
34
|
+
if (!events) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const divs = events.onDiv;
|
|
29
38
|
return ((!!mouse.position && events.onHover.enable && isInArray(bounceMode, events.onHover.mode)) ||
|
|
30
39
|
isDivModeEnabled(bounceMode, divs));
|
|
31
40
|
}
|
package/browser/Utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Circle,
|
|
2
|
-
|
|
1
|
+
import { Circle, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, double, getRangeValue, half, safeDocument, } from "@tsparticles/engine";
|
|
2
|
+
import { DivType, divModeExecute } from "@tsparticles/plugin-interactivity";
|
|
3
|
+
const squareExp = 2, halfPI = Math.PI * half, toleranceFactor = 10, minRadius = 0, minVelocity = 0;
|
|
3
4
|
function processBounce(container, position, radius, area, enabledCb) {
|
|
4
5
|
const query = container.particles.quadTree.query(area, enabledCb);
|
|
5
6
|
for (const particle of query) {
|
|
@@ -39,8 +40,8 @@ export function divBounce(container, divs, bounceMode, enabledCb) {
|
|
|
39
40
|
});
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
|
-
export function mouseBounce(container, enabledCb) {
|
|
43
|
-
const pxRatio = container.retina.pixelRatio, tolerance = toleranceFactor * pxRatio, mousePos =
|
|
43
|
+
export function mouseBounce(container, interactivityData, enabledCb) {
|
|
44
|
+
const pxRatio = container.retina.pixelRatio, tolerance = toleranceFactor * pxRatio, mousePos = interactivityData.mouse.position, radius = container.retina.bounceModeDistance;
|
|
44
45
|
if (!radius || radius < minRadius || !mousePos) {
|
|
45
46
|
return;
|
|
46
47
|
}
|
package/browser/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export function loadExternalBounceInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
3
|
-
engine.register(e => {
|
|
4
|
-
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.4");
|
|
3
|
+
engine.register(async (e) => {
|
|
4
|
+
const { loadInteractivityPlugin } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
loadInteractivityPlugin(e);
|
|
6
|
+
e.addInteractor?.("externalBounce", async (container) => {
|
|
5
7
|
const { Bouncer } = await import("./Bouncer.js");
|
|
6
8
|
return new Bouncer(container);
|
|
7
9
|
});
|
package/cjs/Bouncer.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ExternalInteractorBase, isDivModeEnabled,
|
|
1
|
+
import { ExternalInteractorBase, isDivModeEnabled, mouseMoveEvent, } from "@tsparticles/plugin-interactivity";
|
|
2
|
+
import { isInArray } from "@tsparticles/engine";
|
|
2
3
|
import { divBounce, mouseBounce } from "./Utils.js";
|
|
3
4
|
import { Bounce } from "./Options/Classes/Bounce.js";
|
|
4
5
|
const bounceMode = "bounce";
|
|
@@ -9,23 +10,31 @@ export class Bouncer extends ExternalInteractorBase {
|
|
|
9
10
|
clear() {
|
|
10
11
|
}
|
|
11
12
|
init() {
|
|
12
|
-
const container = this.container, bounce = container.actualOptions.interactivity
|
|
13
|
+
const container = this.container, bounce = container.actualOptions.interactivity?.modes.bounce;
|
|
13
14
|
if (!bounce) {
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
17
|
container.retina.bounceModeDistance = bounce.distance * container.retina.pixelRatio;
|
|
17
18
|
}
|
|
18
|
-
interact() {
|
|
19
|
-
const container = this.container, options = container.actualOptions, events = options.interactivity
|
|
19
|
+
interact(interactivityData) {
|
|
20
|
+
const container = this.container, options = container.actualOptions, events = options.interactivity?.events, mouseMoveStatus = interactivityData.status === mouseMoveEvent;
|
|
21
|
+
if (!events) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv;
|
|
20
25
|
if (mouseMoveStatus && hoverEnabled && isInArray(bounceMode, hoverMode)) {
|
|
21
|
-
mouseBounce(this.container, p => this.isEnabled(p));
|
|
26
|
+
mouseBounce(this.container, interactivityData, p => this.isEnabled(interactivityData, p));
|
|
22
27
|
}
|
|
23
28
|
else {
|
|
24
|
-
divBounce(this.container, divs, bounceMode, p => this.isEnabled(p));
|
|
29
|
+
divBounce(this.container, divs, bounceMode, p => this.isEnabled(interactivityData, p));
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
|
-
isEnabled(particle) {
|
|
28
|
-
const container = this.container, options = container.actualOptions, mouse =
|
|
32
|
+
isEnabled(interactivityData, particle) {
|
|
33
|
+
const container = this.container, options = container.actualOptions, mouse = interactivityData.mouse, events = (particle?.interactivity ?? options.interactivity)?.events;
|
|
34
|
+
if (!events) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const divs = events.onDiv;
|
|
29
38
|
return ((!!mouse.position && events.onHover.enable && isInArray(bounceMode, events.onHover.mode)) ||
|
|
30
39
|
isDivModeEnabled(bounceMode, divs));
|
|
31
40
|
}
|
package/cjs/Utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Circle,
|
|
2
|
-
|
|
1
|
+
import { Circle, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, double, getRangeValue, half, safeDocument, } from "@tsparticles/engine";
|
|
2
|
+
import { DivType, divModeExecute } from "@tsparticles/plugin-interactivity";
|
|
3
|
+
const squareExp = 2, halfPI = Math.PI * half, toleranceFactor = 10, minRadius = 0, minVelocity = 0;
|
|
3
4
|
function processBounce(container, position, radius, area, enabledCb) {
|
|
4
5
|
const query = container.particles.quadTree.query(area, enabledCb);
|
|
5
6
|
for (const particle of query) {
|
|
@@ -39,8 +40,8 @@ export function divBounce(container, divs, bounceMode, enabledCb) {
|
|
|
39
40
|
});
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
|
-
export function mouseBounce(container, enabledCb) {
|
|
43
|
-
const pxRatio = container.retina.pixelRatio, tolerance = toleranceFactor * pxRatio, mousePos =
|
|
43
|
+
export function mouseBounce(container, interactivityData, enabledCb) {
|
|
44
|
+
const pxRatio = container.retina.pixelRatio, tolerance = toleranceFactor * pxRatio, mousePos = interactivityData.mouse.position, radius = container.retina.bounceModeDistance;
|
|
44
45
|
if (!radius || radius < minRadius || !mousePos) {
|
|
45
46
|
return;
|
|
46
47
|
}
|
package/cjs/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export function loadExternalBounceInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
3
|
-
engine.register(e => {
|
|
4
|
-
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.4");
|
|
3
|
+
engine.register(async (e) => {
|
|
4
|
+
const { loadInteractivityPlugin } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
loadInteractivityPlugin(e);
|
|
6
|
+
e.addInteractor?.("externalBounce", async (container) => {
|
|
5
7
|
const { Bouncer } = await import("./Bouncer.js");
|
|
6
8
|
return new Bouncer(container);
|
|
7
9
|
});
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Demo / Generator : https://particles.js.org/
|
|
5
5
|
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
6
|
* How to use? : Check the GitHub README
|
|
7
|
-
* v4.0.0-alpha.
|
|
7
|
+
* v4.0.0-alpha.4
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
\*********************************/
|
|
24
24
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
25
|
|
|
26
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Bouncer: () => (/* binding */ Bouncer)\n/* harmony export */ });\n/* harmony import */ var
|
|
26
|
+
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_plugin_interactivity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n/* harmony import */ var _Options_Classes_Bounce_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Options/Classes/Bounce.js */ \"./dist/browser/Options/Classes/Bounce.js\");\n\n\n\n\nconst bounceMode = \"bounce\";\nclass Bouncer extends _tsparticles_plugin_interactivity__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(interactivityData) {\n const container = this.container,\n options = container.actualOptions,\n events = options.interactivity?.events,\n mouseMoveStatus = interactivityData.status === _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_0__.mouseMoveEvent;\n if (!events) {\n return;\n }\n const hoverEnabled = events.onHover.enable,\n hoverMode = events.onHover.mode,\n divs = events.onDiv;\n if (mouseMoveStatus && hoverEnabled && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.isInArray)(bounceMode, hoverMode)) {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_2__.mouseBounce)(this.container, interactivityData, p => this.isEnabled(interactivityData, p));\n } else {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_2__.divBounce)(this.container, divs, bounceMode, p => this.isEnabled(interactivityData, p));\n }\n }\n isEnabled(interactivityData, particle) {\n const container = this.container,\n options = container.actualOptions,\n mouse = interactivityData.mouse,\n events = (particle?.interactivity ?? options.interactivity)?.events;\n if (!events) {\n return false;\n }\n const divs = events.onDiv;\n return !!mouse.position && events.onHover.enable && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.isInArray)(bounceMode, events.onHover.mode) || (0,_tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_0__.isDivModeEnabled)(bounceMode, divs);\n }\n loadModeOptions(options, ...sources) {\n options.bounce ??= new _Options_Classes_Bounce_js__WEBPACK_IMPORTED_MODULE_3__.Bounce();\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}");
|
|
27
27
|
|
|
28
28
|
/***/ },
|
|
29
29
|
|
|
@@ -33,7 +33,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
33
33
|
\*******************************/
|
|
34
34
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
35
|
|
|
36
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ divBounce: () => (/* binding */ divBounce),\n/* harmony export */ mouseBounce: () => (/* binding */ mouseBounce),\n/* harmony export */ rectBounce: () => (/* binding */ rectBounce)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst squareExp = 2,\n
|
|
36
|
+
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 */ rectBounce: () => (/* binding */ rectBounce)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\");\n\n\nconst squareExp = 2,\n halfPI = Math.PI * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half,\n toleranceFactor = 10,\n minRadius = 0,\n minVelocity = 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 rectBounce(particle, (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.calculateBounds)(position, radius));\n }\n }\n}\nfunction singleSelectorBounce(container, selector, div, bounceCb) {\n const query = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.safeDocument)().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 * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half) * pxRatio,\n y: (elem.offsetTop + elem.offsetHeight * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half) * pxRatio\n },\n radius = elem.offsetWidth * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half * pxRatio,\n tolerance = toleranceFactor * pxRatio,\n area = div.type === _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__.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 * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.double, elem.offsetHeight * pxRatio + tolerance * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.double);\n bounceCb(pos, radius, area);\n });\n}\nfunction divBounce(container, divs, bounceMode, enabledCb) {\n (0,_tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__.divModeExecute)(bounceMode, divs, (selector, div) => {\n singleSelectorBounce(container, selector, div, (pos, radius, area) => {\n processBounce(container, pos, radius, area, enabledCb);\n });\n });\n}\nfunction mouseBounce(container, interactivityData, enabledCb) {\n const pxRatio = container.retina.pixelRatio,\n tolerance = toleranceFactor * pxRatio,\n mousePos = interactivityData.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}\nfunction rectSideBounce(data) {\n const res = {\n bounced: false\n },\n {\n pSide,\n pOtherSide,\n rectSide,\n rectOtherSide,\n velocity,\n factor\n } = data;\n if (pOtherSide.min < rectOtherSide.min || pOtherSide.min > rectOtherSide.max || pOtherSide.max < rectOtherSide.min || pOtherSide.max > rectOtherSide.max) {\n return res;\n }\n if (pSide.max >= rectSide.min && pSide.max <= (rectSide.max + rectSide.min) * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half && velocity > minVelocity || pSide.min <= rectSide.max && pSide.min > (rectSide.max + rectSide.min) * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half && velocity < minVelocity) {\n res.velocity = velocity * -factor;\n res.bounced = true;\n }\n return res;\n}\nfunction rectBounce(particle, divBounds) {\n const pPos = particle.getPosition(),\n size = particle.getRadius(),\n bounds = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.calculateBounds)(pPos, size),\n bounceOptions = particle.options.bounce,\n resH = rectSideBounce({\n pSide: {\n min: bounds.left,\n max: bounds.right\n },\n pOtherSide: {\n min: bounds.top,\n max: bounds.bottom\n },\n rectSide: {\n min: divBounds.left,\n max: divBounds.right\n },\n rectOtherSide: {\n min: divBounds.top,\n max: divBounds.bottom\n },\n velocity: particle.velocity.x,\n factor: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(bounceOptions.horizontal.value)\n });\n if (resH.bounced) {\n if (resH.velocity !== undefined) {\n particle.velocity.x = resH.velocity;\n }\n if (resH.position !== undefined) {\n particle.position.x = resH.position;\n }\n }\n const resV = rectSideBounce({\n pSide: {\n min: bounds.top,\n max: bounds.bottom\n },\n pOtherSide: {\n min: bounds.left,\n max: bounds.right\n },\n rectSide: {\n min: divBounds.top,\n max: divBounds.bottom\n },\n rectOtherSide: {\n min: divBounds.left,\n max: divBounds.right\n },\n velocity: particle.velocity.y,\n factor: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(bounceOptions.vertical.value)\n });\n if (resV.bounced) {\n if (resV.velocity !== undefined) {\n particle.velocity.y = resV.velocity;\n }\n if (resV.position !== undefined) {\n particle.position.y = resV.position;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-external-bounce/./dist/browser/Utils.js?\n}");
|
|
37
37
|
|
|
38
38
|
/***/ }
|
|
39
39
|
|
package/esm/Bouncer.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ExternalInteractorBase, isDivModeEnabled,
|
|
1
|
+
import { ExternalInteractorBase, isDivModeEnabled, mouseMoveEvent, } from "@tsparticles/plugin-interactivity";
|
|
2
|
+
import { isInArray } from "@tsparticles/engine";
|
|
2
3
|
import { divBounce, mouseBounce } from "./Utils.js";
|
|
3
4
|
import { Bounce } from "./Options/Classes/Bounce.js";
|
|
4
5
|
const bounceMode = "bounce";
|
|
@@ -9,23 +10,31 @@ export class Bouncer extends ExternalInteractorBase {
|
|
|
9
10
|
clear() {
|
|
10
11
|
}
|
|
11
12
|
init() {
|
|
12
|
-
const container = this.container, bounce = container.actualOptions.interactivity
|
|
13
|
+
const container = this.container, bounce = container.actualOptions.interactivity?.modes.bounce;
|
|
13
14
|
if (!bounce) {
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
17
|
container.retina.bounceModeDistance = bounce.distance * container.retina.pixelRatio;
|
|
17
18
|
}
|
|
18
|
-
interact() {
|
|
19
|
-
const container = this.container, options = container.actualOptions, events = options.interactivity
|
|
19
|
+
interact(interactivityData) {
|
|
20
|
+
const container = this.container, options = container.actualOptions, events = options.interactivity?.events, mouseMoveStatus = interactivityData.status === mouseMoveEvent;
|
|
21
|
+
if (!events) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv;
|
|
20
25
|
if (mouseMoveStatus && hoverEnabled && isInArray(bounceMode, hoverMode)) {
|
|
21
|
-
mouseBounce(this.container, p => this.isEnabled(p));
|
|
26
|
+
mouseBounce(this.container, interactivityData, p => this.isEnabled(interactivityData, p));
|
|
22
27
|
}
|
|
23
28
|
else {
|
|
24
|
-
divBounce(this.container, divs, bounceMode, p => this.isEnabled(p));
|
|
29
|
+
divBounce(this.container, divs, bounceMode, p => this.isEnabled(interactivityData, p));
|
|
25
30
|
}
|
|
26
31
|
}
|
|
27
|
-
isEnabled(particle) {
|
|
28
|
-
const container = this.container, options = container.actualOptions, mouse =
|
|
32
|
+
isEnabled(interactivityData, particle) {
|
|
33
|
+
const container = this.container, options = container.actualOptions, mouse = interactivityData.mouse, events = (particle?.interactivity ?? options.interactivity)?.events;
|
|
34
|
+
if (!events) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const divs = events.onDiv;
|
|
29
38
|
return ((!!mouse.position && events.onHover.enable && isInArray(bounceMode, events.onHover.mode)) ||
|
|
30
39
|
isDivModeEnabled(bounceMode, divs));
|
|
31
40
|
}
|
package/esm/Utils.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Circle,
|
|
2
|
-
|
|
1
|
+
import { Circle, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, double, getRangeValue, half, safeDocument, } from "@tsparticles/engine";
|
|
2
|
+
import { DivType, divModeExecute } from "@tsparticles/plugin-interactivity";
|
|
3
|
+
const squareExp = 2, halfPI = Math.PI * half, toleranceFactor = 10, minRadius = 0, minVelocity = 0;
|
|
3
4
|
function processBounce(container, position, radius, area, enabledCb) {
|
|
4
5
|
const query = container.particles.quadTree.query(area, enabledCb);
|
|
5
6
|
for (const particle of query) {
|
|
@@ -39,8 +40,8 @@ export function divBounce(container, divs, bounceMode, enabledCb) {
|
|
|
39
40
|
});
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
|
-
export function mouseBounce(container, enabledCb) {
|
|
43
|
-
const pxRatio = container.retina.pixelRatio, tolerance = toleranceFactor * pxRatio, mousePos =
|
|
43
|
+
export function mouseBounce(container, interactivityData, enabledCb) {
|
|
44
|
+
const pxRatio = container.retina.pixelRatio, tolerance = toleranceFactor * pxRatio, mousePos = interactivityData.mouse.position, radius = container.retina.bounceModeDistance;
|
|
44
45
|
if (!radius || radius < minRadius || !mousePos) {
|
|
45
46
|
return;
|
|
46
47
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export function loadExternalBounceInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
3
|
-
engine.register(e => {
|
|
4
|
-
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.4");
|
|
3
|
+
engine.register(async (e) => {
|
|
4
|
+
const { loadInteractivityPlugin } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
loadInteractivityPlugin(e);
|
|
6
|
+
e.addInteractor?.("externalBounce", async (container) => {
|
|
5
7
|
const { Bouncer } = await import("./Bouncer.js");
|
|
6
8
|
return new Bouncer(container);
|
|
7
9
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-external-bounce",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.4",
|
|
4
4
|
"description": "tsParticles bounce external interaction",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -87,7 +87,8 @@
|
|
|
87
87
|
"./package.json": "./package.json"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@tsparticles/engine": "4.0.0-alpha.
|
|
90
|
+
"@tsparticles/engine": "4.0.0-alpha.4",
|
|
91
|
+
"@tsparticles/plugin-interactivity": "4.0.0-alpha.4"
|
|
91
92
|
},
|
|
92
93
|
"publishConfig": {
|
|
93
94
|
"access": "public"
|
package/report.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8"/>
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
6
|
-
<title>@tsparticles/interaction-external-bounce [
|
|
6
|
+
<title>@tsparticles/interaction-external-bounce [21 Jan 2026 at 14:42]</title>
|
|
7
7
|
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
|
|
8
8
|
|
|
9
9
|
<script>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Demo / Generator : https://particles.js.org/
|
|
5
5
|
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
6
|
* How to use? : Check the GitHub README
|
|
7
|
-
* v4.0.0-alpha.
|
|
7
|
+
* v4.0.0-alpha.4
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
*/
|
|
17
17
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
18
18
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
19
|
-
module.exports = factory(require("@tsparticles/engine"));
|
|
19
|
+
module.exports = factory(require("@tsparticles/engine"), require("@tsparticles/plugin-interactivity"));
|
|
20
20
|
else if(typeof define === 'function' && define.amd)
|
|
21
|
-
define(["@tsparticles/engine"], factory);
|
|
21
|
+
define(["@tsparticles/engine", "@tsparticles/plugin-interactivity"], factory);
|
|
22
22
|
else {
|
|
23
|
-
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
|
|
23
|
+
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine"), require("@tsparticles/plugin-interactivity")) : factory(root["window"], root["window"]);
|
|
24
24
|
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
25
25
|
}
|
|
26
|
-
})(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
|
|
26
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__, __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__) => {
|
|
27
27
|
return /******/ (() => { // webpackBootstrap
|
|
28
28
|
/******/ "use strict";
|
|
29
29
|
/******/ var __webpack_modules__ = ({
|
|
@@ -44,7 +44,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
44
44
|
\*******************************/
|
|
45
45
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
46
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\");\nfunction loadExternalBounceInteraction(engine) {\n engine.checkVersion(\"4.0.0-alpha.
|
|
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.4\");\n engine.register(async e => {\n const {\n loadInteractivityPlugin\n } = await Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\", 19));\n loadInteractivityPlugin(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}");
|
|
48
48
|
|
|
49
49
|
/***/ },
|
|
50
50
|
|
|
@@ -56,6 +56,16 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
56
56
|
|
|
57
57
|
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
58
58
|
|
|
59
|
+
/***/ },
|
|
60
|
+
|
|
61
|
+
/***/ "@tsparticles/plugin-interactivity"
|
|
62
|
+
/*!***************************************************************************************************************************************************************************!*\
|
|
63
|
+
!*** external {"commonjs":"@tsparticles/plugin-interactivity","commonjs2":"@tsparticles/plugin-interactivity","amd":"@tsparticles/plugin-interactivity","root":"window"} ***!
|
|
64
|
+
\***************************************************************************************************************************************************************************/
|
|
65
|
+
(module) {
|
|
66
|
+
|
|
67
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__;
|
|
68
|
+
|
|
59
69
|
/***/ }
|
|
60
70
|
|
|
61
71
|
/******/ });
|
|
@@ -94,6 +104,36 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
94
104
|
/******/ __webpack_require__.m = __webpack_modules__;
|
|
95
105
|
/******/
|
|
96
106
|
/************************************************************************/
|
|
107
|
+
/******/ /* webpack/runtime/create fake namespace object */
|
|
108
|
+
/******/ (() => {
|
|
109
|
+
/******/ var getProto = Object.getPrototypeOf ? (obj) => (Object.getPrototypeOf(obj)) : (obj) => (obj.__proto__);
|
|
110
|
+
/******/ var leafPrototypes;
|
|
111
|
+
/******/ // create a fake namespace object
|
|
112
|
+
/******/ // mode & 1: value is a module id, require it
|
|
113
|
+
/******/ // mode & 2: merge all properties of value into the ns
|
|
114
|
+
/******/ // mode & 4: return value when already ns object
|
|
115
|
+
/******/ // mode & 16: return value when it's Promise-like
|
|
116
|
+
/******/ // mode & 8|1: behave like require
|
|
117
|
+
/******/ __webpack_require__.t = function(value, mode) {
|
|
118
|
+
/******/ if(mode & 1) value = this(value);
|
|
119
|
+
/******/ if(mode & 8) return value;
|
|
120
|
+
/******/ if(typeof value === 'object' && value) {
|
|
121
|
+
/******/ if((mode & 4) && value.__esModule) return value;
|
|
122
|
+
/******/ if((mode & 16) && typeof value.then === 'function') return value;
|
|
123
|
+
/******/ }
|
|
124
|
+
/******/ var ns = Object.create(null);
|
|
125
|
+
/******/ __webpack_require__.r(ns);
|
|
126
|
+
/******/ var def = {};
|
|
127
|
+
/******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];
|
|
128
|
+
/******/ for(var current = mode & 2 && value; (typeof current == 'object' || typeof current == 'function') && !~leafPrototypes.indexOf(current); current = getProto(current)) {
|
|
129
|
+
/******/ Object.getOwnPropertyNames(current).forEach((key) => (def[key] = () => (value[key])));
|
|
130
|
+
/******/ }
|
|
131
|
+
/******/ def['default'] = () => (value);
|
|
132
|
+
/******/ __webpack_require__.d(ns, def);
|
|
133
|
+
/******/ return ns;
|
|
134
|
+
/******/ };
|
|
135
|
+
/******/ })();
|
|
136
|
+
/******/
|
|
97
137
|
/******/ /* webpack/runtime/define property getters */
|
|
98
138
|
/******/ (() => {
|
|
99
139
|
/******/ // define getter functions for harmony exports
|
|
@@ -128,18 +168,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
128
168
|
/******/ };
|
|
129
169
|
/******/ })();
|
|
130
170
|
/******/
|
|
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
|
-
/******/
|
|
143
171
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
144
172
|
/******/ (() => {
|
|
145
173
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
@@ -204,8 +232,8 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
204
232
|
/******/ /* webpack/runtime/publicPath */
|
|
205
233
|
/******/ (() => {
|
|
206
234
|
/******/ var scriptUrl;
|
|
207
|
-
/******/ if (
|
|
208
|
-
/******/ var document =
|
|
235
|
+
/******/ if (globalThis.importScripts) scriptUrl = globalThis.location + "";
|
|
236
|
+
/******/ var document = globalThis.document;
|
|
209
237
|
/******/ if (!scriptUrl && document) {
|
|
210
238
|
/******/ if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
|
|
211
239
|
/******/ scriptUrl = document.currentScript.src;
|
|
@@ -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 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
|
|
2
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"),require("@tsparticles/plugin-interactivity"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine","@tsparticles/plugin-interactivity"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine"),require("@tsparticles/plugin-interactivity")):t(e.window,e.window);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,((e,t)=>(()=>{var r,n,o,i,a={303(t){t.exports=e},405(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)}}},702(e){e.exports=t}},c={};function s(e){var t=c[e];if(void 0!==t)return t.exports;var r=c[e]={exports:{}};return a[e](r,r.exports,s),r.exports}s.m=a,n=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,s.t=function(e,t){if(1&t&&(e=this(e)),8&t)return e;if("object"==typeof e&&e){if(4&t&&e.__esModule)return e;if(16&t&&"function"==typeof e.then)return e}var o=Object.create(null);s.r(o);var i={};r=r||[null,n({}),n([]),n(n)];for(var a=2&t&&e;("object"==typeof a||"function"==typeof a)&&!~r.indexOf(a);a=n(a))Object.getOwnPropertyNames(a).forEach((t=>i[t]=()=>e[t]));return i.default=()=>e,s.d(o,i),o},s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce(((t,r)=>(s.f[r](e,t),t)),[])),s.u=e=>e+".min.js",s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o={},i="@tsparticles/interaction-external-bounce:",s.l=(e,t,r,n)=>{if(o[e])o[e].push(t);else{var a,c;if(void 0!==r)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")==i+r){a=p;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",s.nc&&a.setAttribute("nonce",s.nc),a.setAttribute("data-webpack",i+r),a.src=e),o[e]=[t];var d=(t,r)=>{a.onerror=a.onload=null,clearTimeout(f);var n=o[e];if(delete o[e],a.parentNode&&a.parentNode.removeChild(a),n&&n.forEach((e=>e(r))),t)return t(r)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=d.bind(null,a.onerror),a.onload=d.bind(null,a.onload),c&&document.head.appendChild(a)}},s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;globalThis.importScripts&&(e=globalThis.location+"");var t=globalThis.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(/\/[^\/]+$/,"/"),s.p=e})(),(()=>{var e={186:0};s.f.j=(t,r)=>{var n=s.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 i=s.p+s.u(t),a=new Error;s.l(i,(r=>{if(s.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var o=r&&("load"===r.type?"missing":r.type),i=r&&r.target&&r.target.src;a.message="Loading chunk "+t+" failed.\n("+o+": "+i+")",a.name="ChunkLoadError",a.type=o,a.request=i,n[1](a)}}),"chunk-"+t,t)}};var t=(t,r)=>{var n,o,[i,a,c]=r,l=0;if(i.some((t=>0!==e[t]))){for(n in a)s.o(a,n)&&(s.m[n]=a[n]);if(c)c(s)}for(t&&t(r);l<i.length;l++)o=i[l],s.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 l={};s.r(l),s.d(l,{Bounce:()=>u.b,loadExternalBounceInteraction:()=>p});var u=s(405);function p(e){e.checkVersion("4.0.0-alpha.4"),e.register((async e=>{const{loadInteractivityPlugin:t}=await Promise.resolve().then(s.t.bind(s,702,19));t(e),e.addInteractor?.("externalBounce",(async e=>{const{Bouncer:t}=await s.e(820).then(s.bind(s,820));return new t(e)}))}))}return l})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Bounce External Interaction v4.0.0-alpha.
|
|
1
|
+
/*! tsParticles Bounce External Interaction v4.0.0-alpha.4 by Matteo Bruni */
|
package/types/Bouncer.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { BounceContainer, BounceMode, IBounceMode } from "./Types.js";
|
|
2
|
-
import { ExternalInteractorBase, type
|
|
2
|
+
import { ExternalInteractorBase, type IInteractivityData, type IModes, type InteractivityParticle, type Modes } from "@tsparticles/plugin-interactivity";
|
|
3
|
+
import { type RecursivePartial } from "@tsparticles/engine";
|
|
3
4
|
export declare class Bouncer extends ExternalInteractorBase<BounceContainer> {
|
|
4
5
|
constructor(container: BounceContainer);
|
|
5
6
|
clear(): void;
|
|
6
7
|
init(): void;
|
|
7
|
-
interact(): void;
|
|
8
|
-
isEnabled(particle?:
|
|
8
|
+
interact(interactivityData: IInteractivityData): void;
|
|
9
|
+
isEnabled(interactivityData: IInteractivityData, particle?: InteractivityParticle): boolean;
|
|
9
10
|
loadModeOptions(options: Modes & BounceMode, ...sources: RecursivePartial<(IModes & IBounceMode) | undefined>[]): void;
|
|
10
11
|
reset(): void;
|
|
11
12
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BounceMode } from "../../Types.js";
|
|
2
|
-
import type {
|
|
3
|
-
export type BounceOptions =
|
|
4
|
-
interactivity
|
|
2
|
+
import type { InteractivityOptions } from "@tsparticles/plugin-interactivity";
|
|
3
|
+
export type BounceOptions = InteractivityOptions & {
|
|
4
|
+
interactivity?: {
|
|
5
5
|
modes: BounceMode;
|
|
6
6
|
};
|
|
7
7
|
};
|
package/types/Types.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Bounce } from "./Options/Classes/Bounce.js";
|
|
2
2
|
import type { BounceOptions } from "./Options/Classes/BounceOptions.js";
|
|
3
|
-
import type { Container } from "@tsparticles/engine";
|
|
4
3
|
import type { IBounce } from "./Options/Interfaces/IBounce.js";
|
|
4
|
+
import type { InteractivityContainer } from "@tsparticles/plugin-interactivity";
|
|
5
5
|
export interface IBounceMode {
|
|
6
6
|
bounce: IBounce;
|
|
7
7
|
}
|
|
8
8
|
export interface BounceMode {
|
|
9
9
|
bounce?: Bounce;
|
|
10
10
|
}
|
|
11
|
-
export type BounceContainer =
|
|
11
|
+
export type BounceContainer = InteractivityContainer & {
|
|
12
12
|
actualOptions: BounceOptions;
|
|
13
13
|
retina: {
|
|
14
14
|
bounceModeDistance?: number;
|
package/types/Utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type IBounds, type Particle, type SingleOrMultiple } from "@tsparticles/engine";
|
|
2
|
+
import { type DivEvent, type IInteractivityData } from "@tsparticles/plugin-interactivity";
|
|
2
3
|
import type { BounceContainer } from "./Types.js";
|
|
3
4
|
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;
|
|
5
|
+
export declare function mouseBounce(container: BounceContainer, interactivityData: IInteractivityData, enabledCb: (p: Particle) => boolean): void;
|
|
5
6
|
export declare function rectBounce(particle: Particle, divBounds: IBounds): void;
|
package/umd/Bouncer.js
CHANGED
|
@@ -4,42 +4,51 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "@tsparticles/engine", "./Utils.js", "./Options/Classes/Bounce.js"], factory);
|
|
7
|
+
define(["require", "exports", "@tsparticles/plugin-interactivity", "@tsparticles/engine", "./Utils.js", "./Options/Classes/Bounce.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Bouncer = void 0;
|
|
13
|
+
const plugin_interactivity_1 = require("@tsparticles/plugin-interactivity");
|
|
13
14
|
const engine_1 = require("@tsparticles/engine");
|
|
14
15
|
const Utils_js_1 = require("./Utils.js");
|
|
15
16
|
const Bounce_js_1 = require("./Options/Classes/Bounce.js");
|
|
16
17
|
const bounceMode = "bounce";
|
|
17
|
-
class Bouncer extends
|
|
18
|
+
class Bouncer extends plugin_interactivity_1.ExternalInteractorBase {
|
|
18
19
|
constructor(container) {
|
|
19
20
|
super(container);
|
|
20
21
|
}
|
|
21
22
|
clear() {
|
|
22
23
|
}
|
|
23
24
|
init() {
|
|
24
|
-
const container = this.container, bounce = container.actualOptions.interactivity
|
|
25
|
+
const container = this.container, bounce = container.actualOptions.interactivity?.modes.bounce;
|
|
25
26
|
if (!bounce) {
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
29
|
container.retina.bounceModeDistance = bounce.distance * container.retina.pixelRatio;
|
|
29
30
|
}
|
|
30
|
-
interact() {
|
|
31
|
-
const container = this.container, options = container.actualOptions, events = options.interactivity
|
|
31
|
+
interact(interactivityData) {
|
|
32
|
+
const container = this.container, options = container.actualOptions, events = options.interactivity?.events, mouseMoveStatus = interactivityData.status === plugin_interactivity_1.mouseMoveEvent;
|
|
33
|
+
if (!events) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv;
|
|
32
37
|
if (mouseMoveStatus && hoverEnabled && (0, engine_1.isInArray)(bounceMode, hoverMode)) {
|
|
33
|
-
(0, Utils_js_1.mouseBounce)(this.container, p => this.isEnabled(p));
|
|
38
|
+
(0, Utils_js_1.mouseBounce)(this.container, interactivityData, p => this.isEnabled(interactivityData, p));
|
|
34
39
|
}
|
|
35
40
|
else {
|
|
36
|
-
(0, Utils_js_1.divBounce)(this.container, divs, bounceMode, p => this.isEnabled(p));
|
|
41
|
+
(0, Utils_js_1.divBounce)(this.container, divs, bounceMode, p => this.isEnabled(interactivityData, p));
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
|
-
isEnabled(particle) {
|
|
40
|
-
const container = this.container, options = container.actualOptions, mouse =
|
|
44
|
+
isEnabled(interactivityData, particle) {
|
|
45
|
+
const container = this.container, options = container.actualOptions, mouse = interactivityData.mouse, events = (particle?.interactivity ?? options.interactivity)?.events;
|
|
46
|
+
if (!events) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
const divs = events.onDiv;
|
|
41
50
|
return ((!!mouse.position && events.onHover.enable && (0, engine_1.isInArray)(bounceMode, events.onHover.mode)) ||
|
|
42
|
-
(0,
|
|
51
|
+
(0, plugin_interactivity_1.isDivModeEnabled)(bounceMode, divs));
|
|
43
52
|
}
|
|
44
53
|
loadModeOptions(options, ...sources) {
|
|
45
54
|
options.bounce ??= new Bounce_js_1.Bounce();
|
package/umd/Utils.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "@tsparticles/engine"], factory);
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "@tsparticles/plugin-interactivity"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
exports.mouseBounce = mouseBounce;
|
|
14
14
|
exports.rectBounce = rectBounce;
|
|
15
15
|
const engine_1 = require("@tsparticles/engine");
|
|
16
|
-
const
|
|
16
|
+
const plugin_interactivity_1 = require("@tsparticles/plugin-interactivity");
|
|
17
|
+
const squareExp = 2, halfPI = Math.PI * engine_1.half, toleranceFactor = 10, minRadius = 0, minVelocity = 0;
|
|
17
18
|
function processBounce(container, position, radius, area, enabledCb) {
|
|
18
19
|
const query = container.particles.quadTree.query(area, enabledCb);
|
|
19
20
|
for (const particle of query) {
|
|
@@ -38,23 +39,23 @@
|
|
|
38
39
|
}
|
|
39
40
|
query.forEach(item => {
|
|
40
41
|
const elem = item, pxRatio = container.retina.pixelRatio, pos = {
|
|
41
|
-
x: (elem.offsetLeft + elem.offsetWidth * half) * pxRatio,
|
|
42
|
-
y: (elem.offsetTop + elem.offsetHeight * half) * pxRatio,
|
|
43
|
-
}, radius = elem.offsetWidth * half * pxRatio, tolerance = toleranceFactor * pxRatio, area = div.type ===
|
|
42
|
+
x: (elem.offsetLeft + elem.offsetWidth * engine_1.half) * pxRatio,
|
|
43
|
+
y: (elem.offsetTop + elem.offsetHeight * engine_1.half) * pxRatio,
|
|
44
|
+
}, radius = elem.offsetWidth * engine_1.half * pxRatio, tolerance = toleranceFactor * pxRatio, area = div.type === plugin_interactivity_1.DivType.circle
|
|
44
45
|
? new engine_1.Circle(pos.x, pos.y, radius + tolerance)
|
|
45
|
-
: new engine_1.Rectangle(elem.offsetLeft * pxRatio - tolerance, elem.offsetTop * pxRatio - tolerance, elem.offsetWidth * pxRatio + tolerance * double, elem.offsetHeight * pxRatio + tolerance * double);
|
|
46
|
+
: new engine_1.Rectangle(elem.offsetLeft * pxRatio - tolerance, elem.offsetTop * pxRatio - tolerance, elem.offsetWidth * pxRatio + tolerance * engine_1.double, elem.offsetHeight * pxRatio + tolerance * engine_1.double);
|
|
46
47
|
bounceCb(pos, radius, area);
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
50
|
function divBounce(container, divs, bounceMode, enabledCb) {
|
|
50
|
-
(0,
|
|
51
|
+
(0, plugin_interactivity_1.divModeExecute)(bounceMode, divs, (selector, div) => {
|
|
51
52
|
singleSelectorBounce(container, selector, div, (pos, radius, area) => {
|
|
52
53
|
processBounce(container, pos, radius, area, enabledCb);
|
|
53
54
|
});
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
|
-
function mouseBounce(container, enabledCb) {
|
|
57
|
-
const pxRatio = container.retina.pixelRatio, tolerance = toleranceFactor * pxRatio, mousePos =
|
|
57
|
+
function mouseBounce(container, interactivityData, enabledCb) {
|
|
58
|
+
const pxRatio = container.retina.pixelRatio, tolerance = toleranceFactor * pxRatio, mousePos = interactivityData.mouse.position, radius = container.retina.bounceModeDistance;
|
|
58
59
|
if (!radius || radius < minRadius || !mousePos) {
|
|
59
60
|
return;
|
|
60
61
|
}
|
|
@@ -68,8 +69,8 @@
|
|
|
68
69
|
pOtherSide.max > rectOtherSide.max) {
|
|
69
70
|
return res;
|
|
70
71
|
}
|
|
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)) {
|
|
72
|
+
if ((pSide.max >= rectSide.min && pSide.max <= (rectSide.max + rectSide.min) * engine_1.half && velocity > minVelocity) ||
|
|
73
|
+
(pSide.min <= rectSide.max && pSide.min > (rectSide.max + rectSide.min) * engine_1.half && velocity < minVelocity)) {
|
|
73
74
|
res.velocity = velocity * -factor;
|
|
74
75
|
res.bounced = true;
|
|
75
76
|
}
|
package/umd/index.js
CHANGED
|
@@ -48,10 +48,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
48
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
49
|
exports.loadExternalBounceInteraction = loadExternalBounceInteraction;
|
|
50
50
|
function loadExternalBounceInteraction(engine) {
|
|
51
|
-
engine.checkVersion("4.0.0-alpha.
|
|
52
|
-
engine.register(e => {
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
engine.checkVersion("4.0.0-alpha.4");
|
|
52
|
+
engine.register(async (e) => {
|
|
53
|
+
const { loadInteractivityPlugin } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("@tsparticles/plugin-interactivity"))) : new Promise((resolve_1, reject_1) => { require(["@tsparticles/plugin-interactivity"], resolve_1, reject_1); }).then(__importStar));
|
|
54
|
+
loadInteractivityPlugin(e);
|
|
55
|
+
e.addInteractor?.("externalBounce", async (container) => {
|
|
56
|
+
const { Bouncer } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Bouncer.js"))) : new Promise((resolve_2, reject_2) => { require(["./Bouncer.js"], resolve_2, reject_2); }).then(__importStar));
|
|
55
57
|
return new Bouncer(container);
|
|
56
58
|
});
|
|
57
59
|
});
|
package/85.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! For license information please see 85.min.js.LICENSE.txt */
|
|
2
|
-
(this.webpackChunk_tsparticles_interaction_external_bounce=this.webpackChunk_tsparticles_interaction_external_bounce||[]).push([[85],{85(t,e,i){i.d(e,{Bouncer:()=>d});var o=i(303);const n=.5,c=Math.PI*n;function a(t,e,i,n,a){const r=t.particles.quadTree.query(n,a);for(const t of r)n instanceof o.Circle?(0,o.circleBounce)((0,o.circleBounceDataFromParticle)(t),{position:e,radius:i,mass:i**2*c,velocity:o.Vector.origin,factor:o.Vector.origin}):n instanceof o.Rectangle&&l(t,(0,o.calculateBounds)(e,i))}function r(t,e,i,c){(0,o.divModeExecute)(i,e,((e,i)=>{!function(t,e,i,c){const a=(0,o.safeDocument)().querySelectorAll(e);a.length&&a.forEach((e=>{const a=e,r=t.retina.pixelRatio,s={x:(a.offsetLeft+a.offsetWidth*n)*r,y:(a.offsetTop+a.offsetHeight*n)*r},l=a.offsetWidth*n*r,u=10*r,m=i.type===o.DivType.circle?new o.Circle(s.x,s.y,l+u):new o.Rectangle(a.offsetLeft*r-u,a.offsetTop*r-u,a.offsetWidth*r+2*u,a.offsetHeight*r+2*u);c(s,l,m)}))}(t,e,i,((e,i,o)=>{a(t,e,i,o,c)}))}))}function s(t){const e={bounced:!1},{pSide:i,pOtherSide:o,rectSide:c,rectOtherSide:a,velocity:r,factor:s}=t;return o.min<a.min||o.min>a.max||o.max<a.min||o.max>a.max||(i.max>=c.min&&i.max<=(c.max+c.min)*n&&r>0||i.min<=c.max&&i.min>(c.max+c.min)*n&&r<0)&&(e.velocity=r*-s,e.bounced=!0),e}function l(t,e){const i=t.getPosition(),n=t.getRadius(),c=(0,o.calculateBounds)(i,n),a=t.options.bounce,r=s({pSide:{min:c.left,max:c.right},pOtherSide:{min:c.top,max:c.bottom},rectSide:{min:e.left,max:e.right},rectOtherSide:{min:e.top,max:e.bottom},velocity:t.velocity.x,factor:(0,o.getRangeValue)(a.horizontal.value)});r.bounced&&(void 0!==r.velocity&&(t.velocity.x=r.velocity),void 0!==r.position&&(t.position.x=r.position));const l=s({pSide:{min:c.top,max:c.bottom},pOtherSide:{min:c.left,max:c.right},rectSide:{min:e.top,max:e.bottom},rectOtherSide:{min:e.left,max:e.right},velocity:t.velocity.y,factor:(0,o.getRangeValue)(a.vertical.value)});l.bounced&&(void 0!==l.velocity&&(t.velocity.y=l.velocity),void 0!==l.position&&(t.position.y=l.position))}var u=i(786);const m="bounce";class d extends o.ExternalInteractorBase{constructor(t){super(t)}clear(){}init(){const t=this.container,e=t.actualOptions.interactivity.modes.bounce;e&&(t.retina.bounceModeDistance=e.distance*t.retina.pixelRatio)}interact(){const t=this.container,e=t.actualOptions.interactivity.events,i=t.interactivity.status===o.mouseMoveEvent,n=e.onHover.enable,c=e.onHover.mode,s=e.onDiv;i&&n&&(0,o.isInArray)(m,c)?function(t,e){const i=10*t.retina.pixelRatio,n=t.interactivity.mouse.position,c=t.retina.bounceModeDistance;!c||c<0||!n||a(t,n,c,new o.Circle(n.x,n.y,c+i),e)}(this.container,(t=>this.isEnabled(t))):r(this.container,s,m,(t=>this.isEnabled(t)))}isEnabled(t){const e=this.container,i=e.actualOptions,n=e.interactivity.mouse,c=(t?.interactivity??i.interactivity).events,a=c.onDiv;return!!n.position&&c.onHover.enable&&(0,o.isInArray)(m,c.onHover.mode)||(0,o.isDivModeEnabled)(m,a)}loadModeOptions(t,...e){t.bounce??=new u.b;for(const i of e)t.bounce.load(i?.bounce)}reset(){}}}}]);
|
package/85.min.js.LICENSE.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Bounce External Interaction v4.0.0-alpha.3 by Matteo Bruni */
|