@tsparticles/interaction-external-slow 4.0.0-alpha.5 → 4.0.0-beta.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/253.min.js +1 -0
- package/README.md +5 -0
- package/browser/Options/Classes/Slow.js +2 -0
- package/browser/Slower.js +6 -0
- package/browser/index.js +3 -3
- package/cjs/Options/Classes/Slow.js +2 -0
- package/cjs/Slower.js +6 -0
- package/cjs/index.js +3 -3
- package/dist_browser_Slower_js.js +2 -2
- package/esm/Options/Classes/Slow.js +2 -0
- package/esm/Slower.js +6 -0
- package/esm/index.js +3 -3
- package/package.json +3 -3
- package/report.html +3 -3
- package/tsparticles.interaction.external.slow.js +41 -29
- package/tsparticles.interaction.external.slow.min.js +2 -2
- package/types/Slower.d.ts +2 -0
- package/umd/Options/Classes/Slow.js +2 -0
- package/umd/Slower.js +6 -0
- package/umd/index.js +3 -3
- package/361.min.js +0 -2
- package/361.min.js.LICENSE.txt +0 -1
- package/tsparticles.interaction.external.slow.min.js.LICENSE.txt +0 -1
package/253.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_interaction_external_slow=this.webpackChunk_tsparticles_interaction_external_slow||[]).push([[253],{253(t,e,i){i.d(e,{Slower:()=>o});var s=i(702),a=i(303),n=i(268);class o extends s.ExternalInteractorBase{_maxDistance;constructor(t){super(t),this._maxDistance=0}get maxDistance(){return this._maxDistance}clear(t,e,i){(!t.slow.inRange||i)&&(t.slow.factor=1)}init(){let t=this.container,e=t.actualOptions.interactivity?.modes.slow;e&&(this._maxDistance=e.radius,t.retina.slowModeRadius=e.radius*t.retina.pixelRatio)}interact(){}isEnabled(t,e){let i=this.container,s=t.mouse,n=(e?.interactivity??i.actualOptions.interactivity)?.events;return!!n?.onHover.enable&&!!s.position&&(0,a.isInArray)("slow",n.onHover.mode)}loadModeOptions(t,...e){for(let i of(t.slow??=new n.w,e))t.slow.load(i?.slow)}reset(t,e){e.slow.inRange=!1;let i=this.container,s=i.actualOptions,n=t.mouse.position,o=i.retina.slowModeRadius,r=s.interactivity?.modes.slow;if(!r||!o||o<0||!n)return;let l=e.getPosition(),c=(0,a.getDistance)(n,l),u=r.factor,{slow:w}=e;c>o||(w.inRange=!0,w.factor=c/o/u)}}}}]);
|
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 loadExternalSlowInteraction(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 { loadExternalSlowInteraction } = require("@tsparticles/interaction-external-slow");
|
|
61
63
|
|
|
62
64
|
(async () => {
|
|
65
|
+
await loadInteractivityPlugin(tsParticles);
|
|
63
66
|
await loadExternalSlowInteraction(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 { loadExternalSlowInteraction } from "@tsparticles/interaction-external-slow";
|
|
72
76
|
|
|
73
77
|
(async () => {
|
|
78
|
+
await loadInteractivityPlugin(tsParticles);
|
|
74
79
|
await loadExternalSlowInteraction(tsParticles);
|
|
75
80
|
})();
|
|
76
81
|
```
|
package/browser/Slower.js
CHANGED
|
@@ -3,8 +3,13 @@ import { getDistance, isInArray } from "@tsparticles/engine";
|
|
|
3
3
|
import { Slow } from "./Options/Classes/Slow.js";
|
|
4
4
|
const slowMode = "slow", minRadius = 0;
|
|
5
5
|
export class Slower extends ExternalInteractorBase {
|
|
6
|
+
_maxDistance;
|
|
6
7
|
constructor(container) {
|
|
7
8
|
super(container);
|
|
9
|
+
this._maxDistance = 0;
|
|
10
|
+
}
|
|
11
|
+
get maxDistance() {
|
|
12
|
+
return this._maxDistance;
|
|
8
13
|
}
|
|
9
14
|
clear(particle, _delta, force) {
|
|
10
15
|
if (particle.slow.inRange && !force) {
|
|
@@ -17,6 +22,7 @@ export class Slower extends ExternalInteractorBase {
|
|
|
17
22
|
if (!slow) {
|
|
18
23
|
return;
|
|
19
24
|
}
|
|
25
|
+
this._maxDistance = slow.radius;
|
|
20
26
|
container.retina.slowModeRadius = slow.radius * container.retina.pixelRatio;
|
|
21
27
|
}
|
|
22
28
|
interact() {
|
package/browser/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export async function loadExternalSlowInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
2
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
3
3
|
await engine.register(async (e) => {
|
|
4
|
-
const {
|
|
5
|
-
|
|
4
|
+
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
ensureInteractivityPluginLoaded(e);
|
|
6
6
|
e.addInteractor?.("externalSlow", async (container) => {
|
|
7
7
|
const { Slower } = await import("./Slower.js");
|
|
8
8
|
return new Slower(container);
|
package/cjs/Slower.js
CHANGED
|
@@ -3,8 +3,13 @@ import { getDistance, isInArray } from "@tsparticles/engine";
|
|
|
3
3
|
import { Slow } from "./Options/Classes/Slow.js";
|
|
4
4
|
const slowMode = "slow", minRadius = 0;
|
|
5
5
|
export class Slower extends ExternalInteractorBase {
|
|
6
|
+
_maxDistance;
|
|
6
7
|
constructor(container) {
|
|
7
8
|
super(container);
|
|
9
|
+
this._maxDistance = 0;
|
|
10
|
+
}
|
|
11
|
+
get maxDistance() {
|
|
12
|
+
return this._maxDistance;
|
|
8
13
|
}
|
|
9
14
|
clear(particle, _delta, force) {
|
|
10
15
|
if (particle.slow.inRange && !force) {
|
|
@@ -17,6 +22,7 @@ export class Slower extends ExternalInteractorBase {
|
|
|
17
22
|
if (!slow) {
|
|
18
23
|
return;
|
|
19
24
|
}
|
|
25
|
+
this._maxDistance = slow.radius;
|
|
20
26
|
container.retina.slowModeRadius = slow.radius * container.retina.pixelRatio;
|
|
21
27
|
}
|
|
22
28
|
interact() {
|
package/cjs/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export async function loadExternalSlowInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
2
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
3
3
|
await engine.register(async (e) => {
|
|
4
|
-
const {
|
|
5
|
-
|
|
4
|
+
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
ensureInteractivityPluginLoaded(e);
|
|
6
6
|
e.addInteractor?.("externalSlow", async (container) => {
|
|
7
7
|
const { Slower } = await import("./Slower.js");
|
|
8
8
|
return new Slower(container);
|
|
@@ -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.0
|
|
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 */ Slower: () => (/* binding */ Slower)\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_Slow_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Options/Classes/Slow.js */ \"./dist/browser/Options/Classes/Slow.js\");\n\n\n\nconst slowMode = \"slow\"
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Slower: () => (/* binding */ Slower)\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_Slow_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Options/Classes/Slow.js */ \"./dist/browser/Options/Classes/Slow.js\");\n\n\n\nconst slowMode = \"slow\", minRadius = 0;\nclass Slower extends _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_0__.ExternalInteractorBase {\n _maxDistance;\n constructor(container){\n super(container);\n this._maxDistance = 0;\n }\n get maxDistance() {\n return this._maxDistance;\n }\n clear(particle, _delta, force) {\n if (particle.slow.inRange && !force) {\n return;\n }\n particle.slow.factor = 1;\n }\n init() {\n const container = this.container, slow = container.actualOptions.interactivity?.modes.slow;\n if (!slow) {\n return;\n }\n this._maxDistance = slow.radius;\n container.retina.slowModeRadius = slow.radius * container.retina.pixelRatio;\n }\n interact() {}\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)(slowMode, events.onHover.mode);\n }\n loadModeOptions(options, ...sources) {\n options.slow ??= new _Options_Classes_Slow_js__WEBPACK_IMPORTED_MODULE_2__.Slow();\n for (const source of sources){\n options.slow.load(source?.slow);\n }\n }\n reset(interactivityData, particle) {\n particle.slow.inRange = false;\n const container = this.container, options = container.actualOptions, mousePos = interactivityData.mouse.position, radius = container.retina.slowModeRadius, slowOptions = options.interactivity?.modes.slow;\n if (!slowOptions || !radius || radius < minRadius || !mousePos) {\n return;\n }\n const particlePos = particle.getPosition(), dist = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.getDistance)(mousePos, particlePos), proximityFactor = dist / radius, slowFactor = slowOptions.factor, { slow } = particle;\n if (dist > radius) {\n return;\n }\n slow.inRange = true;\n slow.factor = proximityFactor / slowFactor;\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-external-slow/./dist/browser/Slower.js?\n}");
|
|
27
27
|
|
|
28
28
|
/***/ }
|
|
29
29
|
|
package/esm/Slower.js
CHANGED
|
@@ -3,8 +3,13 @@ import { getDistance, isInArray } from "@tsparticles/engine";
|
|
|
3
3
|
import { Slow } from "./Options/Classes/Slow.js";
|
|
4
4
|
const slowMode = "slow", minRadius = 0;
|
|
5
5
|
export class Slower extends ExternalInteractorBase {
|
|
6
|
+
_maxDistance;
|
|
6
7
|
constructor(container) {
|
|
7
8
|
super(container);
|
|
9
|
+
this._maxDistance = 0;
|
|
10
|
+
}
|
|
11
|
+
get maxDistance() {
|
|
12
|
+
return this._maxDistance;
|
|
8
13
|
}
|
|
9
14
|
clear(particle, _delta, force) {
|
|
10
15
|
if (particle.slow.inRange && !force) {
|
|
@@ -17,6 +22,7 @@ export class Slower extends ExternalInteractorBase {
|
|
|
17
22
|
if (!slow) {
|
|
18
23
|
return;
|
|
19
24
|
}
|
|
25
|
+
this._maxDistance = slow.radius;
|
|
20
26
|
container.retina.slowModeRadius = slow.radius * container.retina.pixelRatio;
|
|
21
27
|
}
|
|
22
28
|
interact() {
|
package/esm/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export async function loadExternalSlowInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
2
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
3
3
|
await engine.register(async (e) => {
|
|
4
|
-
const {
|
|
5
|
-
|
|
4
|
+
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
ensureInteractivityPluginLoaded(e);
|
|
6
6
|
e.addInteractor?.("externalSlow", async (container) => {
|
|
7
7
|
const { Slower } = await import("./Slower.js");
|
|
8
8
|
return new Slower(container);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-external-slow",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
4
|
"description": "tsParticles slow 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.0",
|
|
91
|
+
"@tsparticles/plugin-interactivity": "4.0.0-beta.0"
|
|
92
92
|
},
|
|
93
93
|
"publishConfig": {
|
|
94
94
|
"access": "public"
|