@tsparticles/interaction-external-bounce 4.0.0-beta.0 → 4.0.0-beta.10
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/71.min.js +1 -0
- package/README.md +38 -0
- package/browser/index.js +3 -3
- package/cjs/index.js +3 -3
- package/dist_browser_Bouncer_js.js +1 -1
- package/esm/index.js +3 -3
- package/package.json +10 -7
- package/report.html +84 -29
- package/tsparticles.interaction.external.bounce.js +2 -2
- package/tsparticles.interaction.external.bounce.min.js +2 -2
- package/520.min.js +0 -1
- package/umd/Bouncer.js +0 -69
- package/umd/IRectSideResult.js +0 -12
- package/umd/Options/Classes/Bounce.js +0 -29
- package/umd/Options/Classes/BounceOptions.js +0 -12
- package/umd/Options/Interfaces/IBounce.js +0 -12
- package/umd/Types.js +0 -12
- package/umd/Utils.js +0 -137
- package/umd/index.js +0 -62
package/71.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_interaction_external_bounce=this.webpackChunk_tsparticles_interaction_external_bounce||[]).push([[71],{71(e,t,i){i.d(t,{Bouncer:()=>u});var o=i(702),n=i(303);let a=Math.PI*n.half;function c(e,t,i,o,c){for(let l of e.particles.grid.query(o,c))o instanceof n.Circle?(0,n.circleBounce)((0,n.circleBounceDataFromParticle)(l),{position:t,radius:i,mass:i**2*a,velocity:n.Vector.origin,factor:n.Vector.origin}):o instanceof n.Rectangle&&function(e,t){let i=e.getPosition(),o=e.getRadius(),a=(0,n.calculateBounds)(i,o),c=e.options.bounce,l=r({pSide:{min:a.left,max:a.right},pOtherSide:{min:a.top,max:a.bottom},rectSide:{min:t.left,max:t.right},rectOtherSide:{min:t.top,max:t.bottom},velocity:e.velocity.x,factor:(0,n.getRangeValue)(c.horizontal.value)});l.bounced&&(void 0!==l.velocity&&(e.velocity.x=l.velocity),void 0!==l.position&&(e.position.x=l.position));let s=r({pSide:{min:a.top,max:a.bottom},pOtherSide:{min:a.left,max:a.right},rectSide:{min:t.top,max:t.bottom},rectOtherSide:{min:t.left,max:t.right},velocity:e.velocity.y,factor:(0,n.getRangeValue)(c.vertical.value)});s.bounced&&(void 0!==s.velocity&&(e.velocity.y=s.velocity),void 0!==s.position&&(e.position.y=s.position))}(l,(0,n.calculateBounds)(t,i))}function r(e){let t={bounced:!1},{pSide:i,pOtherSide:o,rectSide:a,rectOtherSide:c,velocity:r,factor:l}=e;return o.min<c.min||o.min>c.max||o.max<c.min||o.max>c.max||(i.max>=a.min&&i.max<=(a.max+a.min)*n.half&&r>0||i.min<=a.max&&i.min>(a.max+a.min)*n.half&&r<0)&&(t.velocity=-(r*l),t.bounced=!0),t}var l=i(322);let s="bounce";class u extends o.ExternalInteractorBase{_maxDistance;constructor(e){super(e),this._maxDistance=0}get maxDistance(){return this._maxDistance}clear(){}init(){let e=this.container,t=e.actualOptions.interactivity?.modes.bounce;t&&(this._maxDistance=t.distance,e.retina.bounceModeDistance=t.distance*e.retina.pixelRatio)}interact(e){var t,i,a,r;let l=this.container.actualOptions,u=l.interactivity?.events,m=e.status===o.mouseMoveEvent;if(!u)return;let f=u.onHover.enable,d=u.onHover.mode,v=u.onDiv;if(m&&f&&(0,n.isInArray)(s,d)){let o,a,r;t=this.container,i=t=>this.isEnabled(e,t),o=t.retina.pixelRatio,a=e.mouse.position,(r=t.retina.bounceModeDistance)&&!(r<0)&&a&&c(t,a,r,new n.Circle(a.x,a.y,r+10*o),i)}else a=this.container,r=t=>this.isEnabled(e,t),(0,o.divModeExecute)(s,v,(e,t)=>{let i;(i=(0,n.safeDocument)().querySelectorAll(e)).length&&i.forEach(e=>{let i=a.retina.pixelRatio,l={x:(e.offsetLeft+e.offsetWidth*n.half)*i,y:(e.offsetTop+e.offsetHeight*n.half)*i},s=e.offsetWidth*n.half*i,u=10*i,m=t.type===o.DivType.circle?new n.Circle(l.x,l.y,s+u):new n.Rectangle(e.offsetLeft*i-u,e.offsetTop*i-u,e.offsetWidth*i+u*n.double,e.offsetHeight*i+u*n.double);((e,t,i)=>{c(a,e,t,i,r)})(l,s,m)})})}isEnabled(e,t){let i=this.container.actualOptions,a=e.mouse,c=(t?.interactivity??i.interactivity)?.events;if(!c)return!1;let r=c.onDiv;return!!a.position&&c.onHover.enable&&(0,n.isInArray)(s,c.onHover.mode)||(0,o.isDivModeEnabled)(s,r)}loadModeOptions(e,...t){for(let i of(e.bounce??=new l.b,t))e.bounce.load(i?.bounce)}reset(){}}}}]);
|
package/README.md
CHANGED
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
[tsParticles](https://github.com/tsparticles/tsparticles) interaction plugin for bounce effect around mouse or HTML
|
|
10
10
|
elements.
|
|
11
11
|
|
|
12
|
+
## Quick checklist
|
|
13
|
+
|
|
14
|
+
1. Install `@tsparticles/engine` (or use the CDN bundle below)
|
|
15
|
+
2. Call the package loader function(s) before `tsParticles.load(...)`
|
|
16
|
+
3. Apply the package options in your `tsParticles.load(...)` config
|
|
17
|
+
|
|
12
18
|
## How to use it
|
|
13
19
|
|
|
14
20
|
### CDN / Vanilla JS / jQuery
|
|
@@ -79,3 +85,35 @@ import { loadExternalBounceInteraction } from "@tsparticles/interaction-external
|
|
|
79
85
|
await loadExternalBounceInteraction(tsParticles);
|
|
80
86
|
})();
|
|
81
87
|
```
|
|
88
|
+
|
|
89
|
+
## Option mapping
|
|
90
|
+
|
|
91
|
+
- Event mode key: `interactivity.events.onHover.mode` or `interactivity.events.onClick.mode` with value `"bounce"`
|
|
92
|
+
- Mode options key: `interactivity.modes.bounce`
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"interactivity": {
|
|
97
|
+
"events": {
|
|
98
|
+
"onHover": {
|
|
99
|
+
"enable": true,
|
|
100
|
+
"mode": "bounce"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"modes": {
|
|
104
|
+
"bounce": {}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Common pitfalls
|
|
111
|
+
|
|
112
|
+
- Calling `tsParticles.load(...)` before `loadInteractivityPlugin(...)`
|
|
113
|
+
- Verify required peer packages before enabling advanced options
|
|
114
|
+
- Change one option group at a time to isolate regressions quickly
|
|
115
|
+
|
|
116
|
+
## Related docs
|
|
117
|
+
|
|
118
|
+
- All packages catalog: <https://github.com/tsparticles/tsparticles>
|
|
119
|
+
- Main docs: <https://particles.js.org/docs/>
|
package/browser/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export async function loadExternalBounceInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-beta.
|
|
3
|
-
await engine.register(async (e) => {
|
|
2
|
+
engine.checkVersion("4.0.0-beta.10");
|
|
3
|
+
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
5
|
ensureInteractivityPluginLoaded(e);
|
|
6
|
-
e.addInteractor?.("externalBounce", async (container) => {
|
|
6
|
+
e.pluginManager.addInteractor?.("externalBounce", async (container) => {
|
|
7
7
|
const { Bouncer } = await import("./Bouncer.js");
|
|
8
8
|
return new Bouncer(container);
|
|
9
9
|
});
|
package/cjs/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export async function loadExternalBounceInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-beta.
|
|
3
|
-
await engine.register(async (e) => {
|
|
2
|
+
engine.checkVersion("4.0.0-beta.10");
|
|
3
|
+
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
5
|
ensureInteractivityPluginLoaded(e);
|
|
6
|
-
e.addInteractor?.("externalBounce", async (container) => {
|
|
6
|
+
e.pluginManager.addInteractor?.("externalBounce", async (container) => {
|
|
7
7
|
const { Bouncer } = await import("./Bouncer.js");
|
|
8
8
|
return new Bouncer(container);
|
|
9
9
|
});
|
package/esm/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export async function loadExternalBounceInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-beta.
|
|
3
|
-
await engine.register(async (e) => {
|
|
2
|
+
engine.checkVersion("4.0.0-beta.10");
|
|
3
|
+
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
5
|
ensureInteractivityPluginLoaded(e);
|
|
6
|
-
e.addInteractor?.("externalBounce", async (container) => {
|
|
6
|
+
e.pluginManager.addInteractor?.("externalBounce", async (container) => {
|
|
7
7
|
const { Bouncer } = await import("./Bouncer.js");
|
|
8
8
|
return new Bouncer(container);
|
|
9
9
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-external-bounce",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.10",
|
|
4
4
|
"description": "tsParticles bounce external interaction",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -81,17 +81,20 @@
|
|
|
81
81
|
"browser": "./browser/index.js",
|
|
82
82
|
"import": "./esm/index.js",
|
|
83
83
|
"require": "./cjs/index.js",
|
|
84
|
-
"
|
|
85
|
-
"default": "./cjs/index.js"
|
|
84
|
+
"default": "./esm/index.js"
|
|
86
85
|
},
|
|
87
86
|
"./package.json": "./package.json"
|
|
88
87
|
},
|
|
89
|
-
"
|
|
90
|
-
"@tsparticles/engine": "4.0.0-beta.
|
|
91
|
-
"@tsparticles/plugin-interactivity": "4.0.0-beta.
|
|
88
|
+
"peerDepdendencies": {
|
|
89
|
+
"@tsparticles/engine": "4.0.0-beta.1",
|
|
90
|
+
"@tsparticles/plugin-interactivity": "4.0.0-beta.1"
|
|
92
91
|
},
|
|
93
92
|
"publishConfig": {
|
|
94
93
|
"access": "public"
|
|
95
94
|
},
|
|
96
|
-
"type": "module"
|
|
95
|
+
"type": "module",
|
|
96
|
+
"peerDependencies": {
|
|
97
|
+
"@tsparticles/engine": "4.0.0-beta.10",
|
|
98
|
+
"@tsparticles/plugin-interactivity": "4.0.0-beta.10"
|
|
99
|
+
}
|
|
97
100
|
}
|