@tsparticles/interaction-external-parallax 4.0.0-alpha.8 → 4.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/203.min.js +1 -0
- package/README.md +5 -0
- package/browser/Options/Classes/Parallax.js +2 -0
- package/browser/Parallaxer.js +1 -0
- package/browser/index.js +5 -5
- package/cjs/Options/Classes/Parallax.js +2 -0
- package/cjs/Parallaxer.js +1 -0
- package/cjs/index.js +5 -5
- package/dist_browser_Parallaxer_js.js +2 -2
- package/esm/Options/Classes/Parallax.js +2 -0
- package/esm/Parallaxer.js +1 -0
- package/esm/index.js +5 -5
- package/package.json +3 -3
- package/report.html +84 -29
- package/tsparticles.interaction.external.parallax.js +41 -29
- package/tsparticles.interaction.external.parallax.min.js +2 -2
- package/types/Parallaxer.d.ts +1 -0
- package/umd/Options/Classes/Parallax.js +2 -0
- package/umd/Parallaxer.js +1 -0
- package/umd/index.js +5 -5
- package/411.min.js +0 -2
- package/411.min.js.LICENSE.txt +0 -1
- package/tsparticles.interaction.external.parallax.min.js.LICENSE.txt +0 -1
package/203.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_interaction_external_parallax=this.webpackChunk_tsparticles_interaction_external_parallax||[]).push([[203],{203(a,t,e){e.d(t,{Parallaxer:()=>n});var r=e(321),i=e(303),l=e(702);class n extends r.ExternalInteractorBase{maxDistance=0;constructor(a){super(a)}clear(){}init(){}interact(a){for(let t of this.container.particles.filter(t=>this.isEnabled(a,t)))this._parallaxInteract(a,t)}isEnabled(a,t){let e=this.container,r=a.mouse,l=(t?.interactivity??e.actualOptions.interactivity)?.events;return!!l?.onHover.enable&&!!r.position&&(0,i.isInArray)("parallax",l.onHover.mode)}loadModeOptions(a,...t){for(let e of(a.parallax??=new l.k,t))a.parallax.load(e?.parallax)}reset(){}_parallaxInteract(a,t){if(!this.isEnabled(a,t))return;let e=this.container,r=e.actualOptions,l=r.interactivity?.modes.parallax;if(!l)return;let n=l.force,s=a.mouse.position;if(!s)return;let o=e.canvas.size,c={x:o.width*i.half,y:o.height*i.half},x=l.smooth,p=t.getRadius()/n,h={x:(s.x-c.x)*p,y:(s.y-c.y)*p},{offset:u}=t;u.x+=(h.x-u.x)/x,u.y+=(h.y-u.y)/x}}}}]);
|
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@ Once the scripts are loaded you can set up `tsParticles` and the interaction plu
|
|
|
28
28
|
|
|
29
29
|
```javascript
|
|
30
30
|
(async () => {
|
|
31
|
+
await loadInteractivityPlugin(tsParticles);
|
|
31
32
|
await loadExternalParallaxInteraction(tsParticles);
|
|
32
33
|
|
|
33
34
|
await tsParticles.load({
|
|
@@ -57,9 +58,11 @@ Then you need to import it in the app, like this:
|
|
|
57
58
|
|
|
58
59
|
```javascript
|
|
59
60
|
const { tsParticles } = require("@tsparticles/engine");
|
|
61
|
+
const { loadInteractivityPlugin } = require("@tsparticles/plugin-interactivity");
|
|
60
62
|
const { loadExternalParallaxInteraction } = require("@tsparticles/interaction-external-parallax");
|
|
61
63
|
|
|
62
64
|
(async () => {
|
|
65
|
+
await loadInteractivityPlugin(tsParticles);
|
|
63
66
|
await loadExternalParallaxInteraction(tsParticles);
|
|
64
67
|
})();
|
|
65
68
|
```
|
|
@@ -68,9 +71,11 @@ or
|
|
|
68
71
|
|
|
69
72
|
```javascript
|
|
70
73
|
import { tsParticles } from "@tsparticles/engine";
|
|
74
|
+
import { loadInteractivityPlugin } from "@tsparticles/plugin-interactivity";
|
|
71
75
|
import { loadExternalParallaxInteraction } from "@tsparticles/interaction-external-parallax";
|
|
72
76
|
|
|
73
77
|
(async () => {
|
|
78
|
+
await loadInteractivityPlugin(tsParticles);
|
|
74
79
|
await loadExternalParallaxInteraction(tsParticles);
|
|
75
80
|
})();
|
|
76
81
|
```
|
package/browser/Parallaxer.js
CHANGED
|
@@ -3,6 +3,7 @@ import { half, isInArray } from "@tsparticles/engine";
|
|
|
3
3
|
import { Parallax } from "./Options/Classes/Parallax.js";
|
|
4
4
|
const parallaxMode = "parallax";
|
|
5
5
|
export class Parallaxer extends ExternalInteractorBase {
|
|
6
|
+
maxDistance = 0;
|
|
6
7
|
constructor(container) {
|
|
7
8
|
super(container);
|
|
8
9
|
}
|
package/browser/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export async function loadExternalParallaxInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(async (e) => {
|
|
4
|
-
const {
|
|
5
|
-
|
|
6
|
-
e.addInteractor?.("externalParallax", async (container) => {
|
|
2
|
+
engine.checkVersion("4.0.0-beta.1");
|
|
3
|
+
await engine.pluginManager.register(async (e) => {
|
|
4
|
+
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
ensureInteractivityPluginLoaded(e);
|
|
6
|
+
e.pluginManager.addInteractor?.("externalParallax", async (container) => {
|
|
7
7
|
const { Parallaxer } = await import("./Parallaxer.js");
|
|
8
8
|
return new Parallaxer(container);
|
|
9
9
|
});
|
package/cjs/Parallaxer.js
CHANGED
|
@@ -3,6 +3,7 @@ import { half, isInArray } from "@tsparticles/engine";
|
|
|
3
3
|
import { Parallax } from "./Options/Classes/Parallax.js";
|
|
4
4
|
const parallaxMode = "parallax";
|
|
5
5
|
export class Parallaxer extends ExternalInteractorBase {
|
|
6
|
+
maxDistance = 0;
|
|
6
7
|
constructor(container) {
|
|
7
8
|
super(container);
|
|
8
9
|
}
|
package/cjs/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export async function loadExternalParallaxInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(async (e) => {
|
|
4
|
-
const {
|
|
5
|
-
|
|
6
|
-
e.addInteractor?.("externalParallax", async (container) => {
|
|
2
|
+
engine.checkVersion("4.0.0-beta.1");
|
|
3
|
+
await engine.pluginManager.register(async (e) => {
|
|
4
|
+
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
ensureInteractivityPluginLoaded(e);
|
|
6
|
+
e.pluginManager.addInteractor?.("externalParallax", async (container) => {
|
|
7
7
|
const { Parallaxer } = await import("./Parallaxer.js");
|
|
8
8
|
return new Parallaxer(container);
|
|
9
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-
|
|
7
|
+
* v4.0.0-beta.1
|
|
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 */ Parallaxer: () => (/* binding */ Parallaxer)\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 _Options_Classes_Parallax_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Options/Classes/Parallax.js */ \"./dist/browser/Options/Classes/Parallax.js\");\n\n\n\nconst parallaxMode = \"parallax\";\nclass Parallaxer extends _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_0__.ExternalInteractorBase {\n
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Parallaxer: () => (/* binding */ Parallaxer)\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 _Options_Classes_Parallax_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Options/Classes/Parallax.js */ \"./dist/browser/Options/Classes/Parallax.js\");\n\n\n\nconst parallaxMode = \"parallax\";\nclass Parallaxer extends _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_0__.ExternalInteractorBase {\n maxDistance = 0;\n constructor(container){\n super(container);\n }\n clear() {}\n init() {}\n interact(interactivityData) {\n for (const particle of this.container.particles.filter((p)=>this.isEnabled(interactivityData, p))){\n this._parallaxInteract(interactivityData, particle);\n }\n }\n isEnabled(interactivityData, particle) {\n const container = this.container, mouse = interactivityData.mouse, events = (particle?.interactivity ?? container.actualOptions.interactivity)?.events;\n return !!events?.onHover.enable && !!mouse.position && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.isInArray)(parallaxMode, events.onHover.mode);\n }\n loadModeOptions(options, ...sources) {\n options.parallax ??= new _Options_Classes_Parallax_js__WEBPACK_IMPORTED_MODULE_2__.Parallax();\n for (const source of sources){\n options.parallax.load(source?.parallax);\n }\n }\n reset() {}\n _parallaxInteract(interactivityData, particle) {\n if (!this.isEnabled(interactivityData, particle)) {\n return;\n }\n const container = this.container, options = container.actualOptions, parallaxOptions = options.interactivity?.modes.parallax;\n if (!parallaxOptions) {\n return;\n }\n const parallaxForce = parallaxOptions.force, mousePos = interactivityData.mouse.position;\n if (!mousePos) {\n return;\n }\n const canvasSize = container.canvas.size, canvasCenter = {\n x: canvasSize.width * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.half,\n y: canvasSize.height * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.half\n }, parallaxSmooth = parallaxOptions.smooth, factor = particle.getRadius() / parallaxForce, centerDistance = {\n x: (mousePos.x - canvasCenter.x) * factor,\n y: (mousePos.y - canvasCenter.y) * factor\n }, { offset } = particle;\n offset.x += (centerDistance.x - offset.x) / parallaxSmooth;\n offset.y += (centerDistance.y - offset.y) / parallaxSmooth;\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-external-parallax/./dist/browser/Parallaxer.js?\n}");
|
|
27
27
|
|
|
28
28
|
/***/ }
|
|
29
29
|
|
package/esm/Parallaxer.js
CHANGED
|
@@ -3,6 +3,7 @@ import { half, isInArray } from "@tsparticles/engine";
|
|
|
3
3
|
import { Parallax } from "./Options/Classes/Parallax.js";
|
|
4
4
|
const parallaxMode = "parallax";
|
|
5
5
|
export class Parallaxer extends ExternalInteractorBase {
|
|
6
|
+
maxDistance = 0;
|
|
6
7
|
constructor(container) {
|
|
7
8
|
super(container);
|
|
8
9
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export async function loadExternalParallaxInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
3
|
-
await engine.register(async (e) => {
|
|
4
|
-
const {
|
|
5
|
-
|
|
6
|
-
e.addInteractor?.("externalParallax", async (container) => {
|
|
2
|
+
engine.checkVersion("4.0.0-beta.1");
|
|
3
|
+
await engine.pluginManager.register(async (e) => {
|
|
4
|
+
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
ensureInteractivityPluginLoaded(e);
|
|
6
|
+
e.pluginManager.addInteractor?.("externalParallax", async (container) => {
|
|
7
7
|
const { Parallaxer } = await import("./Parallaxer.js");
|
|
8
8
|
return new Parallaxer(container);
|
|
9
9
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-external-parallax",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta.1",
|
|
4
4
|
"description": "tsParticles parallax external interaction",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
"./package.json": "./package.json"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@tsparticles/engine": "4.0.0-
|
|
91
|
-
"@tsparticles/plugin-interactivity": "4.0.0-
|
|
90
|
+
"@tsparticles/engine": "4.0.0-beta.1",
|
|
91
|
+
"@tsparticles/plugin-interactivity": "4.0.0-beta.1"
|
|
92
92
|
},
|
|
93
93
|
"publishConfig": {
|
|
94
94
|
"access": "public"
|