@tsparticles/interaction-external-bounce 3.9.1 → 4.0.0-alpha.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.
- package/85.min.js +2 -0
- package/85.min.js.LICENSE.txt +1 -0
- package/browser/Bouncer.js +1 -3
- package/browser/IRectSideResult.js +1 -0
- package/browser/Utils.js +81 -4
- package/browser/index.js +8 -7
- package/cjs/Bouncer.js +11 -17
- package/cjs/IRectSideResult.js +1 -0
- package/cjs/Options/Classes/Bounce.js +3 -7
- package/cjs/Options/Classes/BounceOptions.js +1 -2
- package/cjs/Options/Interfaces/IBounce.js +1 -2
- package/cjs/Types.js +1 -2
- package/cjs/Utils.js +93 -20
- package/cjs/index.js +9 -25
- package/dist_browser_Bouncer_js.js +40 -0
- package/esm/Bouncer.js +1 -3
- package/esm/IRectSideResult.js +1 -0
- package/esm/Utils.js +81 -4
- package/esm/index.js +8 -7
- package/package.json +4 -3
- package/report.html +5 -4
- package/tsparticles.interaction.external.bounce.js +213 -44
- package/tsparticles.interaction.external.bounce.min.js +1 -1
- package/tsparticles.interaction.external.bounce.min.js.LICENSE.txt +1 -1
- package/types/IRectSideResult.d.ts +5 -0
- package/types/Utils.d.ts +2 -1
- package/types/index.d.ts +2 -2
- package/umd/Bouncer.js +1 -3
- package/umd/IRectSideResult.js +12 -0
- package/umd/Utils.js +82 -4
- package/umd/index.js +32 -8
package/85.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
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(){}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Bounce External Interaction v4.0.0-alpha.0 by Matteo Bruni */
|
package/browser/Bouncer.js
CHANGED
|
@@ -30,9 +30,7 @@ export class Bouncer extends ExternalInteractorBase {
|
|
|
30
30
|
isDivModeEnabled(bounceMode, divs));
|
|
31
31
|
}
|
|
32
32
|
loadModeOptions(options, ...sources) {
|
|
33
|
-
|
|
34
|
-
options.bounce = new Bounce();
|
|
35
|
-
}
|
|
33
|
+
options.bounce ??= new Bounce();
|
|
36
34
|
for (const source of sources) {
|
|
37
35
|
options.bounce.load(source?.bounce);
|
|
38
36
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/browser/Utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Circle, DivType, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, divModeExecute,
|
|
2
|
-
const squareExp = 2, half = 0.5, halfPI = Math.PI * half, double = 2, toleranceFactor = 10, minRadius = 0;
|
|
1
|
+
import { Circle, DivType, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, divModeExecute, getRangeValue, safeDocument, } from "@tsparticles/engine";
|
|
2
|
+
const squareExp = 2, half = 0.5, halfPI = Math.PI * half, double = 2, toleranceFactor = 10, minRadius = 0, minVelocity = 0;
|
|
3
3
|
function processBounce(container, position, radius, area, enabledCb) {
|
|
4
4
|
const query = container.particles.quadTree.query(area, enabledCb);
|
|
5
5
|
for (const particle of query) {
|
|
@@ -18,7 +18,7 @@ function processBounce(container, position, radius, area, enabledCb) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
function singleSelectorBounce(container, selector, div, bounceCb) {
|
|
21
|
-
const query =
|
|
21
|
+
const query = safeDocument().querySelectorAll(selector);
|
|
22
22
|
if (!query.length) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
@@ -33,7 +33,11 @@ function singleSelectorBounce(container, selector, div, bounceCb) {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
export function divBounce(container, divs, bounceMode, enabledCb) {
|
|
36
|
-
divModeExecute(bounceMode, divs, (selector, div) =>
|
|
36
|
+
divModeExecute(bounceMode, divs, (selector, div) => {
|
|
37
|
+
singleSelectorBounce(container, selector, div, (pos, radius, area) => {
|
|
38
|
+
processBounce(container, pos, radius, area, enabledCb);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
37
41
|
}
|
|
38
42
|
export function mouseBounce(container, enabledCb) {
|
|
39
43
|
const pxRatio = container.retina.pixelRatio, tolerance = toleranceFactor * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
|
|
@@ -42,3 +46,76 @@ export function mouseBounce(container, enabledCb) {
|
|
|
42
46
|
}
|
|
43
47
|
processBounce(container, mousePos, radius, new Circle(mousePos.x, mousePos.y, radius + tolerance), enabledCb);
|
|
44
48
|
}
|
|
49
|
+
function rectSideBounce(data) {
|
|
50
|
+
const res = { bounced: false }, { pSide, pOtherSide, rectSide, rectOtherSide, velocity, factor } = data;
|
|
51
|
+
if (pOtherSide.min < rectOtherSide.min ||
|
|
52
|
+
pOtherSide.min > rectOtherSide.max ||
|
|
53
|
+
pOtherSide.max < rectOtherSide.min ||
|
|
54
|
+
pOtherSide.max > rectOtherSide.max) {
|
|
55
|
+
return res;
|
|
56
|
+
}
|
|
57
|
+
if ((pSide.max >= rectSide.min && pSide.max <= (rectSide.max + rectSide.min) * half && velocity > minVelocity) ||
|
|
58
|
+
(pSide.min <= rectSide.max && pSide.min > (rectSide.max + rectSide.min) * half && velocity < minVelocity)) {
|
|
59
|
+
res.velocity = velocity * -factor;
|
|
60
|
+
res.bounced = true;
|
|
61
|
+
}
|
|
62
|
+
return res;
|
|
63
|
+
}
|
|
64
|
+
export function rectBounce(particle, divBounds) {
|
|
65
|
+
const pPos = particle.getPosition(), size = particle.getRadius(), bounds = calculateBounds(pPos, size), bounceOptions = particle.options.bounce, resH = rectSideBounce({
|
|
66
|
+
pSide: {
|
|
67
|
+
min: bounds.left,
|
|
68
|
+
max: bounds.right,
|
|
69
|
+
},
|
|
70
|
+
pOtherSide: {
|
|
71
|
+
min: bounds.top,
|
|
72
|
+
max: bounds.bottom,
|
|
73
|
+
},
|
|
74
|
+
rectSide: {
|
|
75
|
+
min: divBounds.left,
|
|
76
|
+
max: divBounds.right,
|
|
77
|
+
},
|
|
78
|
+
rectOtherSide: {
|
|
79
|
+
min: divBounds.top,
|
|
80
|
+
max: divBounds.bottom,
|
|
81
|
+
},
|
|
82
|
+
velocity: particle.velocity.x,
|
|
83
|
+
factor: getRangeValue(bounceOptions.horizontal.value),
|
|
84
|
+
});
|
|
85
|
+
if (resH.bounced) {
|
|
86
|
+
if (resH.velocity !== undefined) {
|
|
87
|
+
particle.velocity.x = resH.velocity;
|
|
88
|
+
}
|
|
89
|
+
if (resH.position !== undefined) {
|
|
90
|
+
particle.position.x = resH.position;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const resV = rectSideBounce({
|
|
94
|
+
pSide: {
|
|
95
|
+
min: bounds.top,
|
|
96
|
+
max: bounds.bottom,
|
|
97
|
+
},
|
|
98
|
+
pOtherSide: {
|
|
99
|
+
min: bounds.left,
|
|
100
|
+
max: bounds.right,
|
|
101
|
+
},
|
|
102
|
+
rectSide: {
|
|
103
|
+
min: divBounds.top,
|
|
104
|
+
max: divBounds.bottom,
|
|
105
|
+
},
|
|
106
|
+
rectOtherSide: {
|
|
107
|
+
min: divBounds.left,
|
|
108
|
+
max: divBounds.right,
|
|
109
|
+
},
|
|
110
|
+
velocity: particle.velocity.y,
|
|
111
|
+
factor: getRangeValue(bounceOptions.vertical.value),
|
|
112
|
+
});
|
|
113
|
+
if (resV.bounced) {
|
|
114
|
+
if (resV.velocity !== undefined) {
|
|
115
|
+
particle.velocity.y = resV.velocity;
|
|
116
|
+
}
|
|
117
|
+
if (resV.position !== undefined) {
|
|
118
|
+
particle.position.y = resV.position;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
package/browser/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function loadExternalBounceInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addInteractor("externalBounce", async (container) => {
|
|
5
|
+
const { Bouncer } = await import("./Bouncer.js");
|
|
6
|
+
return new Bouncer(container);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
7
9
|
}
|
|
8
10
|
export * from "./Options/Classes/Bounce.js";
|
|
9
|
-
export * from "./Options/Interfaces/IBounce.js";
|
package/cjs/Bouncer.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
const Utils_js_1 = require("./Utils.js");
|
|
6
|
-
const Bounce_js_1 = require("./Options/Classes/Bounce.js");
|
|
1
|
+
import { ExternalInteractorBase, isDivModeEnabled, isInArray, mouseMoveEvent, } from "@tsparticles/engine";
|
|
2
|
+
import { divBounce, mouseBounce } from "./Utils.js";
|
|
3
|
+
import { Bounce } from "./Options/Classes/Bounce.js";
|
|
7
4
|
const bounceMode = "bounce";
|
|
8
|
-
class Bouncer extends
|
|
5
|
+
export class Bouncer extends ExternalInteractorBase {
|
|
9
6
|
constructor(container) {
|
|
10
7
|
super(container);
|
|
11
8
|
}
|
|
@@ -19,23 +16,21 @@ class Bouncer extends engine_1.ExternalInteractorBase {
|
|
|
19
16
|
container.retina.bounceModeDistance = bounce.distance * container.retina.pixelRatio;
|
|
20
17
|
}
|
|
21
18
|
interact() {
|
|
22
|
-
const container = this.container, options = container.actualOptions, events = options.interactivity.events, mouseMoveStatus = container.interactivity.status ===
|
|
23
|
-
if (mouseMoveStatus && hoverEnabled &&
|
|
24
|
-
|
|
19
|
+
const container = this.container, options = container.actualOptions, events = options.interactivity.events, mouseMoveStatus = container.interactivity.status === mouseMoveEvent, hoverEnabled = events.onHover.enable, hoverMode = events.onHover.mode, divs = events.onDiv;
|
|
20
|
+
if (mouseMoveStatus && hoverEnabled && isInArray(bounceMode, hoverMode)) {
|
|
21
|
+
mouseBounce(this.container, p => this.isEnabled(p));
|
|
25
22
|
}
|
|
26
23
|
else {
|
|
27
|
-
|
|
24
|
+
divBounce(this.container, divs, bounceMode, p => this.isEnabled(p));
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
27
|
isEnabled(particle) {
|
|
31
28
|
const container = this.container, options = container.actualOptions, mouse = container.interactivity.mouse, events = (particle?.interactivity ?? options.interactivity).events, divs = events.onDiv;
|
|
32
|
-
return ((!!mouse.position && events.onHover.enable &&
|
|
33
|
-
|
|
29
|
+
return ((!!mouse.position && events.onHover.enable && isInArray(bounceMode, events.onHover.mode)) ||
|
|
30
|
+
isDivModeEnabled(bounceMode, divs));
|
|
34
31
|
}
|
|
35
32
|
loadModeOptions(options, ...sources) {
|
|
36
|
-
|
|
37
|
-
options.bounce = new Bounce_js_1.Bounce();
|
|
38
|
-
}
|
|
33
|
+
options.bounce ??= new Bounce();
|
|
39
34
|
for (const source of sources) {
|
|
40
35
|
options.bounce.load(source?.bounce);
|
|
41
36
|
}
|
|
@@ -43,4 +38,3 @@ class Bouncer extends engine_1.ExternalInteractorBase {
|
|
|
43
38
|
reset() {
|
|
44
39
|
}
|
|
45
40
|
}
|
|
46
|
-
exports.Bouncer = Bouncer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Bounce = void 0;
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
class Bounce {
|
|
1
|
+
import { isNull } from "@tsparticles/engine";
|
|
2
|
+
export class Bounce {
|
|
6
3
|
constructor() {
|
|
7
4
|
this.distance = 200;
|
|
8
5
|
}
|
|
9
6
|
load(data) {
|
|
10
|
-
if (
|
|
7
|
+
if (isNull(data)) {
|
|
11
8
|
return;
|
|
12
9
|
}
|
|
13
10
|
if (data.distance !== undefined) {
|
|
@@ -15,4 +12,3 @@ class Bounce {
|
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
|
-
exports.Bounce = Bounce;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/Types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/Utils.js
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.divBounce = divBounce;
|
|
4
|
-
exports.mouseBounce = mouseBounce;
|
|
5
|
-
const engine_1 = require("@tsparticles/engine");
|
|
6
|
-
const squareExp = 2, half = 0.5, halfPI = Math.PI * half, double = 2, toleranceFactor = 10, minRadius = 0;
|
|
1
|
+
import { Circle, DivType, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, divModeExecute, getRangeValue, safeDocument, } from "@tsparticles/engine";
|
|
2
|
+
const squareExp = 2, half = 0.5, halfPI = Math.PI * half, double = 2, toleranceFactor = 10, minRadius = 0, minVelocity = 0;
|
|
7
3
|
function processBounce(container, position, radius, area, enabledCb) {
|
|
8
4
|
const query = container.particles.quadTree.query(area, enabledCb);
|
|
9
5
|
for (const particle of query) {
|
|
10
|
-
if (area instanceof
|
|
11
|
-
|
|
6
|
+
if (area instanceof Circle) {
|
|
7
|
+
circleBounce(circleBounceDataFromParticle(particle), {
|
|
12
8
|
position,
|
|
13
9
|
radius,
|
|
14
10
|
mass: radius ** squareExp * halfPI,
|
|
15
|
-
velocity:
|
|
16
|
-
factor:
|
|
11
|
+
velocity: Vector.origin,
|
|
12
|
+
factor: Vector.origin,
|
|
17
13
|
});
|
|
18
14
|
}
|
|
19
|
-
else if (area instanceof
|
|
20
|
-
|
|
15
|
+
else if (area instanceof Rectangle) {
|
|
16
|
+
rectBounce(particle, calculateBounds(position, radius));
|
|
21
17
|
}
|
|
22
18
|
}
|
|
23
19
|
}
|
|
24
20
|
function singleSelectorBounce(container, selector, div, bounceCb) {
|
|
25
|
-
const query =
|
|
21
|
+
const query = safeDocument().querySelectorAll(selector);
|
|
26
22
|
if (!query.length) {
|
|
27
23
|
return;
|
|
28
24
|
}
|
|
@@ -30,19 +26,96 @@ function singleSelectorBounce(container, selector, div, bounceCb) {
|
|
|
30
26
|
const elem = item, pxRatio = container.retina.pixelRatio, pos = {
|
|
31
27
|
x: (elem.offsetLeft + elem.offsetWidth * half) * pxRatio,
|
|
32
28
|
y: (elem.offsetTop + elem.offsetHeight * half) * pxRatio,
|
|
33
|
-
}, radius = elem.offsetWidth * half * pxRatio, tolerance = toleranceFactor * pxRatio, area = div.type ===
|
|
34
|
-
? new
|
|
35
|
-
: new
|
|
29
|
+
}, radius = elem.offsetWidth * half * pxRatio, tolerance = toleranceFactor * pxRatio, area = div.type === DivType.circle
|
|
30
|
+
? new Circle(pos.x, pos.y, radius + tolerance)
|
|
31
|
+
: new Rectangle(elem.offsetLeft * pxRatio - tolerance, elem.offsetTop * pxRatio - tolerance, elem.offsetWidth * pxRatio + tolerance * double, elem.offsetHeight * pxRatio + tolerance * double);
|
|
36
32
|
bounceCb(pos, radius, area);
|
|
37
33
|
});
|
|
38
34
|
}
|
|
39
|
-
function divBounce(container, divs, bounceMode, enabledCb) {
|
|
40
|
-
|
|
35
|
+
export function divBounce(container, divs, bounceMode, enabledCb) {
|
|
36
|
+
divModeExecute(bounceMode, divs, (selector, div) => {
|
|
37
|
+
singleSelectorBounce(container, selector, div, (pos, radius, area) => {
|
|
38
|
+
processBounce(container, pos, radius, area, enabledCb);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
41
|
}
|
|
42
|
-
function mouseBounce(container, enabledCb) {
|
|
42
|
+
export function mouseBounce(container, enabledCb) {
|
|
43
43
|
const pxRatio = container.retina.pixelRatio, tolerance = toleranceFactor * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
|
|
44
44
|
if (!radius || radius < minRadius || !mousePos) {
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
processBounce(container, mousePos, radius, new
|
|
47
|
+
processBounce(container, mousePos, radius, new Circle(mousePos.x, mousePos.y, radius + tolerance), enabledCb);
|
|
48
|
+
}
|
|
49
|
+
function rectSideBounce(data) {
|
|
50
|
+
const res = { bounced: false }, { pSide, pOtherSide, rectSide, rectOtherSide, velocity, factor } = data;
|
|
51
|
+
if (pOtherSide.min < rectOtherSide.min ||
|
|
52
|
+
pOtherSide.min > rectOtherSide.max ||
|
|
53
|
+
pOtherSide.max < rectOtherSide.min ||
|
|
54
|
+
pOtherSide.max > rectOtherSide.max) {
|
|
55
|
+
return res;
|
|
56
|
+
}
|
|
57
|
+
if ((pSide.max >= rectSide.min && pSide.max <= (rectSide.max + rectSide.min) * half && velocity > minVelocity) ||
|
|
58
|
+
(pSide.min <= rectSide.max && pSide.min > (rectSide.max + rectSide.min) * half && velocity < minVelocity)) {
|
|
59
|
+
res.velocity = velocity * -factor;
|
|
60
|
+
res.bounced = true;
|
|
61
|
+
}
|
|
62
|
+
return res;
|
|
63
|
+
}
|
|
64
|
+
export function rectBounce(particle, divBounds) {
|
|
65
|
+
const pPos = particle.getPosition(), size = particle.getRadius(), bounds = calculateBounds(pPos, size), bounceOptions = particle.options.bounce, resH = rectSideBounce({
|
|
66
|
+
pSide: {
|
|
67
|
+
min: bounds.left,
|
|
68
|
+
max: bounds.right,
|
|
69
|
+
},
|
|
70
|
+
pOtherSide: {
|
|
71
|
+
min: bounds.top,
|
|
72
|
+
max: bounds.bottom,
|
|
73
|
+
},
|
|
74
|
+
rectSide: {
|
|
75
|
+
min: divBounds.left,
|
|
76
|
+
max: divBounds.right,
|
|
77
|
+
},
|
|
78
|
+
rectOtherSide: {
|
|
79
|
+
min: divBounds.top,
|
|
80
|
+
max: divBounds.bottom,
|
|
81
|
+
},
|
|
82
|
+
velocity: particle.velocity.x,
|
|
83
|
+
factor: getRangeValue(bounceOptions.horizontal.value),
|
|
84
|
+
});
|
|
85
|
+
if (resH.bounced) {
|
|
86
|
+
if (resH.velocity !== undefined) {
|
|
87
|
+
particle.velocity.x = resH.velocity;
|
|
88
|
+
}
|
|
89
|
+
if (resH.position !== undefined) {
|
|
90
|
+
particle.position.x = resH.position;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const resV = rectSideBounce({
|
|
94
|
+
pSide: {
|
|
95
|
+
min: bounds.top,
|
|
96
|
+
max: bounds.bottom,
|
|
97
|
+
},
|
|
98
|
+
pOtherSide: {
|
|
99
|
+
min: bounds.left,
|
|
100
|
+
max: bounds.right,
|
|
101
|
+
},
|
|
102
|
+
rectSide: {
|
|
103
|
+
min: divBounds.top,
|
|
104
|
+
max: divBounds.bottom,
|
|
105
|
+
},
|
|
106
|
+
rectOtherSide: {
|
|
107
|
+
min: divBounds.left,
|
|
108
|
+
max: divBounds.right,
|
|
109
|
+
},
|
|
110
|
+
velocity: particle.velocity.y,
|
|
111
|
+
factor: getRangeValue(bounceOptions.vertical.value),
|
|
112
|
+
});
|
|
113
|
+
if (resV.bounced) {
|
|
114
|
+
if (resV.velocity !== undefined) {
|
|
115
|
+
particle.velocity.y = resV.velocity;
|
|
116
|
+
}
|
|
117
|
+
if (resV.position !== undefined) {
|
|
118
|
+
particle.position.y = resV.position;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
48
121
|
}
|
package/cjs/index.js
CHANGED
|
@@ -1,26 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.loadExternalBounceInteraction = loadExternalBounceInteraction;
|
|
18
|
-
const Bouncer_js_1 = require("./Bouncer.js");
|
|
19
|
-
async function loadExternalBounceInteraction(engine, refresh = true) {
|
|
20
|
-
engine.checkVersion("3.9.1");
|
|
21
|
-
await engine.addInteractor("externalBounce", container => {
|
|
22
|
-
return Promise.resolve(new Bouncer_js_1.Bouncer(container));
|
|
23
|
-
}, refresh);
|
|
1
|
+
export function loadExternalBounceInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addInteractor("externalBounce", async (container) => {
|
|
5
|
+
const { Bouncer } = await import("./Bouncer.js");
|
|
6
|
+
return new Bouncer(container);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
24
9
|
}
|
|
25
|
-
|
|
26
|
-
__exportStar(require("./Options/Interfaces/IBounce.js"), exports);
|
|
10
|
+
export * from "./Options/Classes/Bounce.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v4.0.0-alpha.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_interaction_external_bounce"] = this["webpackChunk_tsparticles_interaction_external_bounce"] || []).push([["dist_browser_Bouncer_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/Bouncer.js"
|
|
21
|
+
/*!*********************************!*\
|
|
22
|
+
!*** ./dist/browser/Bouncer.js ***!
|
|
23
|
+
\*********************************/
|
|
24
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
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 _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n/* harmony import */ var _Options_Classes_Bounce_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Options/Classes/Bounce.js */ \"./dist/browser/Options/Classes/Bounce.js\");\n\n\n\nconst bounceMode = \"bounce\";\nclass Bouncer extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ExternalInteractorBase {\n constructor(container) {\n super(container);\n }\n clear() {}\n init() {\n const container = this.container,\n bounce = container.actualOptions.interactivity.modes.bounce;\n if (!bounce) {\n return;\n }\n container.retina.bounceModeDistance = bounce.distance * container.retina.pixelRatio;\n }\n interact() {\n const container = this.container,\n options = container.actualOptions,\n events = options.interactivity.events,\n mouseMoveStatus = container.interactivity.status === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.mouseMoveEvent,\n hoverEnabled = events.onHover.enable,\n hoverMode = events.onHover.mode,\n divs = events.onDiv;\n if (mouseMoveStatus && hoverEnabled && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(bounceMode, hoverMode)) {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.mouseBounce)(this.container, p => this.isEnabled(p));\n } else {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.divBounce)(this.container, divs, bounceMode, p => this.isEnabled(p));\n }\n }\n isEnabled(particle) {\n const container = this.container,\n options = container.actualOptions,\n mouse = container.interactivity.mouse,\n events = (particle?.interactivity ?? options.interactivity).events,\n divs = events.onDiv;\n return !!mouse.position && events.onHover.enable && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isInArray)(bounceMode, events.onHover.mode) || (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isDivModeEnabled)(bounceMode, divs);\n }\n loadModeOptions(options, ...sources) {\n options.bounce ??= new _Options_Classes_Bounce_js__WEBPACK_IMPORTED_MODULE_2__.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
|
+
|
|
28
|
+
/***/ },
|
|
29
|
+
|
|
30
|
+
/***/ "./dist/browser/Utils.js"
|
|
31
|
+
/*!*******************************!*\
|
|
32
|
+
!*** ./dist/browser/Utils.js ***!
|
|
33
|
+
\*******************************/
|
|
34
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
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 half = 0.5,\n halfPI = Math.PI * half,\n double = 2,\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 * half) * pxRatio,\n y: (elem.offsetTop + elem.offsetHeight * half) * pxRatio\n },\n radius = elem.offsetWidth * half * pxRatio,\n tolerance = toleranceFactor * pxRatio,\n area = div.type === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.DivType.circle ? new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Circle(pos.x, pos.y, radius + tolerance) : new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Rectangle(elem.offsetLeft * pxRatio - tolerance, elem.offsetTop * pxRatio - tolerance, elem.offsetWidth * pxRatio + tolerance * double, elem.offsetHeight * pxRatio + tolerance * double);\n bounceCb(pos, radius, area);\n });\n}\nfunction divBounce(container, divs, bounceMode, enabledCb) {\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.divModeExecute)(bounceMode, divs, (selector, div) => {\n singleSelectorBounce(container, selector, div, (pos, radius, area) => {\n processBounce(container, pos, radius, area, enabledCb);\n });\n });\n}\nfunction mouseBounce(container, enabledCb) {\n const pxRatio = container.retina.pixelRatio,\n tolerance = toleranceFactor * pxRatio,\n mousePos = container.interactivity.mouse.position,\n radius = container.retina.bounceModeDistance;\n if (!radius || radius < minRadius || !mousePos) {\n return;\n }\n processBounce(container, mousePos, radius, new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Circle(mousePos.x, mousePos.y, radius + tolerance), enabledCb);\n}\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) * half && velocity > minVelocity || pSide.min <= rectSide.max && pSide.min > (rectSide.max + rectSide.min) * 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
|
+
|
|
38
|
+
/***/ }
|
|
39
|
+
|
|
40
|
+
}]);
|
package/esm/Bouncer.js
CHANGED
|
@@ -30,9 +30,7 @@ export class Bouncer extends ExternalInteractorBase {
|
|
|
30
30
|
isDivModeEnabled(bounceMode, divs));
|
|
31
31
|
}
|
|
32
32
|
loadModeOptions(options, ...sources) {
|
|
33
|
-
|
|
34
|
-
options.bounce = new Bounce();
|
|
35
|
-
}
|
|
33
|
+
options.bounce ??= new Bounce();
|
|
36
34
|
for (const source of sources) {
|
|
37
35
|
options.bounce.load(source?.bounce);
|
|
38
36
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/Utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Circle, DivType, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, divModeExecute,
|
|
2
|
-
const squareExp = 2, half = 0.5, halfPI = Math.PI * half, double = 2, toleranceFactor = 10, minRadius = 0;
|
|
1
|
+
import { Circle, DivType, Rectangle, Vector, calculateBounds, circleBounce, circleBounceDataFromParticle, divModeExecute, getRangeValue, safeDocument, } from "@tsparticles/engine";
|
|
2
|
+
const squareExp = 2, half = 0.5, halfPI = Math.PI * half, double = 2, toleranceFactor = 10, minRadius = 0, minVelocity = 0;
|
|
3
3
|
function processBounce(container, position, radius, area, enabledCb) {
|
|
4
4
|
const query = container.particles.quadTree.query(area, enabledCb);
|
|
5
5
|
for (const particle of query) {
|
|
@@ -18,7 +18,7 @@ function processBounce(container, position, radius, area, enabledCb) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
function singleSelectorBounce(container, selector, div, bounceCb) {
|
|
21
|
-
const query =
|
|
21
|
+
const query = safeDocument().querySelectorAll(selector);
|
|
22
22
|
if (!query.length) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
@@ -33,7 +33,11 @@ function singleSelectorBounce(container, selector, div, bounceCb) {
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
export function divBounce(container, divs, bounceMode, enabledCb) {
|
|
36
|
-
divModeExecute(bounceMode, divs, (selector, div) =>
|
|
36
|
+
divModeExecute(bounceMode, divs, (selector, div) => {
|
|
37
|
+
singleSelectorBounce(container, selector, div, (pos, radius, area) => {
|
|
38
|
+
processBounce(container, pos, radius, area, enabledCb);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
37
41
|
}
|
|
38
42
|
export function mouseBounce(container, enabledCb) {
|
|
39
43
|
const pxRatio = container.retina.pixelRatio, tolerance = toleranceFactor * pxRatio, mousePos = container.interactivity.mouse.position, radius = container.retina.bounceModeDistance;
|
|
@@ -42,3 +46,76 @@ export function mouseBounce(container, enabledCb) {
|
|
|
42
46
|
}
|
|
43
47
|
processBounce(container, mousePos, radius, new Circle(mousePos.x, mousePos.y, radius + tolerance), enabledCb);
|
|
44
48
|
}
|
|
49
|
+
function rectSideBounce(data) {
|
|
50
|
+
const res = { bounced: false }, { pSide, pOtherSide, rectSide, rectOtherSide, velocity, factor } = data;
|
|
51
|
+
if (pOtherSide.min < rectOtherSide.min ||
|
|
52
|
+
pOtherSide.min > rectOtherSide.max ||
|
|
53
|
+
pOtherSide.max < rectOtherSide.min ||
|
|
54
|
+
pOtherSide.max > rectOtherSide.max) {
|
|
55
|
+
return res;
|
|
56
|
+
}
|
|
57
|
+
if ((pSide.max >= rectSide.min && pSide.max <= (rectSide.max + rectSide.min) * half && velocity > minVelocity) ||
|
|
58
|
+
(pSide.min <= rectSide.max && pSide.min > (rectSide.max + rectSide.min) * half && velocity < minVelocity)) {
|
|
59
|
+
res.velocity = velocity * -factor;
|
|
60
|
+
res.bounced = true;
|
|
61
|
+
}
|
|
62
|
+
return res;
|
|
63
|
+
}
|
|
64
|
+
export function rectBounce(particle, divBounds) {
|
|
65
|
+
const pPos = particle.getPosition(), size = particle.getRadius(), bounds = calculateBounds(pPos, size), bounceOptions = particle.options.bounce, resH = rectSideBounce({
|
|
66
|
+
pSide: {
|
|
67
|
+
min: bounds.left,
|
|
68
|
+
max: bounds.right,
|
|
69
|
+
},
|
|
70
|
+
pOtherSide: {
|
|
71
|
+
min: bounds.top,
|
|
72
|
+
max: bounds.bottom,
|
|
73
|
+
},
|
|
74
|
+
rectSide: {
|
|
75
|
+
min: divBounds.left,
|
|
76
|
+
max: divBounds.right,
|
|
77
|
+
},
|
|
78
|
+
rectOtherSide: {
|
|
79
|
+
min: divBounds.top,
|
|
80
|
+
max: divBounds.bottom,
|
|
81
|
+
},
|
|
82
|
+
velocity: particle.velocity.x,
|
|
83
|
+
factor: getRangeValue(bounceOptions.horizontal.value),
|
|
84
|
+
});
|
|
85
|
+
if (resH.bounced) {
|
|
86
|
+
if (resH.velocity !== undefined) {
|
|
87
|
+
particle.velocity.x = resH.velocity;
|
|
88
|
+
}
|
|
89
|
+
if (resH.position !== undefined) {
|
|
90
|
+
particle.position.x = resH.position;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const resV = rectSideBounce({
|
|
94
|
+
pSide: {
|
|
95
|
+
min: bounds.top,
|
|
96
|
+
max: bounds.bottom,
|
|
97
|
+
},
|
|
98
|
+
pOtherSide: {
|
|
99
|
+
min: bounds.left,
|
|
100
|
+
max: bounds.right,
|
|
101
|
+
},
|
|
102
|
+
rectSide: {
|
|
103
|
+
min: divBounds.top,
|
|
104
|
+
max: divBounds.bottom,
|
|
105
|
+
},
|
|
106
|
+
rectOtherSide: {
|
|
107
|
+
min: divBounds.left,
|
|
108
|
+
max: divBounds.right,
|
|
109
|
+
},
|
|
110
|
+
velocity: particle.velocity.y,
|
|
111
|
+
factor: getRangeValue(bounceOptions.vertical.value),
|
|
112
|
+
});
|
|
113
|
+
if (resV.bounced) {
|
|
114
|
+
if (resV.velocity !== undefined) {
|
|
115
|
+
particle.velocity.y = resV.velocity;
|
|
116
|
+
}
|
|
117
|
+
if (resV.position !== undefined) {
|
|
118
|
+
particle.position.y = resV.position;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
package/esm/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function loadExternalBounceInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addInteractor("externalBounce", async (container) => {
|
|
5
|
+
const { Bouncer } = await import("./Bouncer.js");
|
|
6
|
+
return new Bouncer(container);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
7
9
|
}
|
|
8
10
|
export * from "./Options/Classes/Bounce.js";
|
|
9
|
-
export * from "./Options/Interfaces/IBounce.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-external-bounce",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.0",
|
|
4
4
|
"description": "tsParticles bounce external interaction",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -87,9 +87,10 @@
|
|
|
87
87
|
"./package.json": "./package.json"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@tsparticles/engine": "
|
|
90
|
+
"@tsparticles/engine": "4.0.0-alpha.0"
|
|
91
91
|
},
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"access": "public"
|
|
94
|
-
}
|
|
94
|
+
},
|
|
95
|
+
"type": "module"
|
|
95
96
|
}
|