@tsparticles/interaction-external-slow 4.0.0-alpha.2 → 4.0.0-alpha.20
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/642.min.js +1 -0
- package/README.md +19 -14
- package/browser/Options/Classes/Slow.js +2 -0
- package/browser/Slower.js +8 -7
- package/browser/index.js +6 -4
- package/cjs/Options/Classes/Slow.js +2 -0
- package/cjs/Slower.js +8 -7
- package/cjs/index.js +6 -4
- package/dist_browser_Slower_js.js +2 -2
- package/esm/Options/Classes/Slow.js +2 -0
- package/esm/Slower.js +8 -7
- package/esm/index.js +6 -4
- package/package.json +3 -2
- package/report.html +3 -3
- package/tsparticles.interaction.external.slow.js +57 -17
- package/tsparticles.interaction.external.slow.min.js +2 -2
- package/types/Options/Classes/SlowOptions.d.ts +3 -3
- package/types/Slower.d.ts +4 -3
- package/types/Types.d.ts +2 -2
- package/types/index.d.ts +1 -1
- package/umd/Options/Classes/Slow.js +2 -0
- package/umd/Slower.js +9 -8
- package/umd/index.js +7 -5
- package/366.min.js +0 -2
- package/366.min.js.LICENSE.txt +0 -1
- package/tsparticles.interaction.external.slow.min.js.LICENSE.txt +0 -1
package/642.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_interaction_external_slow=this.webpackChunk_tsparticles_interaction_external_slow||[]).push([[642],{642(t,e,i){i.d(e,{Slower:()=>a});var o=i(702),n=i(303),s=i(279);class a extends o.ExternalInteractorBase{constructor(t){super(t)}clear(t,e,i){(!t.slow.inRange||i)&&(t.slow.factor=1)}init(){let t=this.container,e=t.actualOptions.interactivity?.modes.slow;e&&(t.retina.slowModeRadius=e.radius*t.retina.pixelRatio)}interact(){}isEnabled(t,e){let i=this.container,o=t.mouse,s=(e?.interactivity??i.actualOptions.interactivity)?.events;return!!s?.onHover.enable&&!!o.position&&(0,n.isInArray)("slow",s.onHover.mode)}loadModeOptions(t,...e){for(let i of(t.slow??=new s.w,e))t.slow.load(i?.slow)}reset(t,e){e.slow.inRange=!1;let i=this.container,o=i.actualOptions,s=t.mouse.position,a=i.retina.slowModeRadius,r=o.interactivity?.modes.slow;if(!r||!a||a<0||!s)return;let l=e.getPosition(),c=(0,n.getDistance)(s,l),w=r.factor,{slow:u}=e;c>a||(u.inRange=!0,u.factor=c/a/w)}}}}]);
|
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[](https://particles.js.org)
|
|
2
2
|
|
|
3
|
-
# tsParticles External
|
|
3
|
+
# tsParticles External Slow Interaction
|
|
4
4
|
|
|
5
|
-
[](https://www.jsdelivr.com/package/npm/@tsparticles/interaction-external-slow)
|
|
6
|
+
[](https://www.npmjs.com/package/@tsparticles/interaction-external-slow)
|
|
7
|
+
[](https://www.npmjs.com/package/@tsparticles/interaction-external-slow) [](https://github.com/sponsors/matteobruni)
|
|
8
8
|
|
|
9
|
-
[tsParticles](https://github.com/tsparticles/tsparticles) interaction plugin for
|
|
9
|
+
[tsParticles](https://github.com/tsparticles/tsparticles) interaction plugin for slow effect around mouse or HTML
|
|
10
10
|
elements.
|
|
11
11
|
|
|
12
12
|
## How to use it
|
|
@@ -15,11 +15,11 @@ elements.
|
|
|
15
15
|
|
|
16
16
|
The CDN/Vanilla version JS has one required file in vanilla configuration:
|
|
17
17
|
|
|
18
|
-
Including the `tsparticles.interaction.external.
|
|
18
|
+
Including the `tsparticles.interaction.external.slow.min.js` file will export the function to load the interaction
|
|
19
19
|
plugin:
|
|
20
20
|
|
|
21
21
|
```javascript
|
|
22
|
-
|
|
22
|
+
loadExternalSlowInteraction;
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
### Usage
|
|
@@ -28,7 +28,8 @@ Once the scripts are loaded you can set up `tsParticles` and the interaction plu
|
|
|
28
28
|
|
|
29
29
|
```javascript
|
|
30
30
|
(async () => {
|
|
31
|
-
await
|
|
31
|
+
await loadInteractivityPlugin(tsParticles);
|
|
32
|
+
await loadExternalSlowInteraction(tsParticles);
|
|
32
33
|
|
|
33
34
|
await tsParticles.load({
|
|
34
35
|
id: "tsparticles",
|
|
@@ -44,23 +45,25 @@ Once the scripts are loaded you can set up `tsParticles` and the interaction plu
|
|
|
44
45
|
This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
|
|
45
46
|
|
|
46
47
|
```shell
|
|
47
|
-
$ npm install @tsparticles/interaction-external-
|
|
48
|
+
$ npm install @tsparticles/interaction-external-slow
|
|
48
49
|
```
|
|
49
50
|
|
|
50
51
|
or
|
|
51
52
|
|
|
52
53
|
```shell
|
|
53
|
-
$ yarn add @tsparticles/interaction-external-
|
|
54
|
+
$ yarn add @tsparticles/interaction-external-slow
|
|
54
55
|
```
|
|
55
56
|
|
|
56
57
|
Then you need to import it in the app, like this:
|
|
57
58
|
|
|
58
59
|
```javascript
|
|
59
60
|
const { tsParticles } = require("@tsparticles/engine");
|
|
60
|
-
const {
|
|
61
|
+
const { loadInteractivityPlugin } = require("@tsparticles/plugin-interactivity");
|
|
62
|
+
const { loadExternalSlowInteraction } = require("@tsparticles/interaction-external-slow");
|
|
61
63
|
|
|
62
64
|
(async () => {
|
|
63
|
-
await
|
|
65
|
+
await loadInteractivityPlugin(tsParticles);
|
|
66
|
+
await loadExternalSlowInteraction(tsParticles);
|
|
64
67
|
})();
|
|
65
68
|
```
|
|
66
69
|
|
|
@@ -68,9 +71,11 @@ or
|
|
|
68
71
|
|
|
69
72
|
```javascript
|
|
70
73
|
import { tsParticles } from "@tsparticles/engine";
|
|
71
|
-
import {
|
|
74
|
+
import { loadInteractivityPlugin } from "@tsparticles/plugin-interactivity";
|
|
75
|
+
import { loadExternalSlowInteraction } from "@tsparticles/interaction-external-slow";
|
|
72
76
|
|
|
73
77
|
(async () => {
|
|
74
|
-
await
|
|
78
|
+
await loadInteractivityPlugin(tsParticles);
|
|
79
|
+
await loadExternalSlowInteraction(tsParticles);
|
|
75
80
|
})();
|
|
76
81
|
```
|
package/browser/Slower.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ExternalInteractorBase,
|
|
1
|
+
import { ExternalInteractorBase, } from "@tsparticles/plugin-interactivity";
|
|
2
|
+
import { getDistance, isInArray } from "@tsparticles/engine";
|
|
2
3
|
import { Slow } from "./Options/Classes/Slow.js";
|
|
3
4
|
const slowMode = "slow", minRadius = 0;
|
|
4
5
|
export class Slower extends ExternalInteractorBase {
|
|
@@ -12,7 +13,7 @@ export class Slower extends ExternalInteractorBase {
|
|
|
12
13
|
particle.slow.factor = 1;
|
|
13
14
|
}
|
|
14
15
|
init() {
|
|
15
|
-
const container = this.container, slow = container.actualOptions.interactivity
|
|
16
|
+
const container = this.container, slow = container.actualOptions.interactivity?.modes.slow;
|
|
16
17
|
if (!slow) {
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
@@ -20,9 +21,9 @@ export class Slower extends ExternalInteractorBase {
|
|
|
20
21
|
}
|
|
21
22
|
interact() {
|
|
22
23
|
}
|
|
23
|
-
isEnabled(particle) {
|
|
24
|
-
const container = this.container, mouse =
|
|
25
|
-
return events
|
|
24
|
+
isEnabled(interactivityData, particle) {
|
|
25
|
+
const container = this.container, mouse = interactivityData.mouse, events = (particle?.interactivity ?? container.actualOptions.interactivity)?.events;
|
|
26
|
+
return !!events?.onHover.enable && !!mouse.position && isInArray(slowMode, events.onHover.mode);
|
|
26
27
|
}
|
|
27
28
|
loadModeOptions(options, ...sources) {
|
|
28
29
|
options.slow ??= new Slow();
|
|
@@ -30,9 +31,9 @@ export class Slower extends ExternalInteractorBase {
|
|
|
30
31
|
options.slow.load(source?.slow);
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
reset(particle) {
|
|
34
|
+
reset(interactivityData, particle) {
|
|
34
35
|
particle.slow.inRange = false;
|
|
35
|
-
const container = this.container, options = container.actualOptions, mousePos =
|
|
36
|
+
const container = this.container, options = container.actualOptions, mousePos = interactivityData.mouse.position, radius = container.retina.slowModeRadius, slowOptions = options.interactivity?.modes.slow;
|
|
36
37
|
if (!slowOptions || !radius || radius < minRadius || !mousePos) {
|
|
37
38
|
return;
|
|
38
39
|
}
|
package/browser/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export function loadExternalSlowInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
3
|
-
engine.register(e => {
|
|
4
|
-
|
|
1
|
+
export async function loadExternalSlowInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.20");
|
|
3
|
+
await engine.register(async (e) => {
|
|
4
|
+
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
ensureInteractivityPluginLoaded(e);
|
|
6
|
+
e.addInteractor?.("externalSlow", async (container) => {
|
|
5
7
|
const { Slower } = await import("./Slower.js");
|
|
6
8
|
return new Slower(container);
|
|
7
9
|
});
|
package/cjs/Slower.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ExternalInteractorBase,
|
|
1
|
+
import { ExternalInteractorBase, } from "@tsparticles/plugin-interactivity";
|
|
2
|
+
import { getDistance, isInArray } from "@tsparticles/engine";
|
|
2
3
|
import { Slow } from "./Options/Classes/Slow.js";
|
|
3
4
|
const slowMode = "slow", minRadius = 0;
|
|
4
5
|
export class Slower extends ExternalInteractorBase {
|
|
@@ -12,7 +13,7 @@ export class Slower extends ExternalInteractorBase {
|
|
|
12
13
|
particle.slow.factor = 1;
|
|
13
14
|
}
|
|
14
15
|
init() {
|
|
15
|
-
const container = this.container, slow = container.actualOptions.interactivity
|
|
16
|
+
const container = this.container, slow = container.actualOptions.interactivity?.modes.slow;
|
|
16
17
|
if (!slow) {
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
@@ -20,9 +21,9 @@ export class Slower extends ExternalInteractorBase {
|
|
|
20
21
|
}
|
|
21
22
|
interact() {
|
|
22
23
|
}
|
|
23
|
-
isEnabled(particle) {
|
|
24
|
-
const container = this.container, mouse =
|
|
25
|
-
return events
|
|
24
|
+
isEnabled(interactivityData, particle) {
|
|
25
|
+
const container = this.container, mouse = interactivityData.mouse, events = (particle?.interactivity ?? container.actualOptions.interactivity)?.events;
|
|
26
|
+
return !!events?.onHover.enable && !!mouse.position && isInArray(slowMode, events.onHover.mode);
|
|
26
27
|
}
|
|
27
28
|
loadModeOptions(options, ...sources) {
|
|
28
29
|
options.slow ??= new Slow();
|
|
@@ -30,9 +31,9 @@ export class Slower extends ExternalInteractorBase {
|
|
|
30
31
|
options.slow.load(source?.slow);
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
reset(particle) {
|
|
34
|
+
reset(interactivityData, particle) {
|
|
34
35
|
particle.slow.inRange = false;
|
|
35
|
-
const container = this.container, options = container.actualOptions, mousePos =
|
|
36
|
+
const container = this.container, options = container.actualOptions, mousePos = interactivityData.mouse.position, radius = container.retina.slowModeRadius, slowOptions = options.interactivity?.modes.slow;
|
|
36
37
|
if (!slowOptions || !radius || radius < minRadius || !mousePos) {
|
|
37
38
|
return;
|
|
38
39
|
}
|
package/cjs/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export function loadExternalSlowInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
3
|
-
engine.register(e => {
|
|
4
|
-
|
|
1
|
+
export async function loadExternalSlowInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.20");
|
|
3
|
+
await engine.register(async (e) => {
|
|
4
|
+
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
ensureInteractivityPluginLoaded(e);
|
|
6
|
+
e.addInteractor?.("externalSlow", async (container) => {
|
|
5
7
|
const { Slower } = await import("./Slower.js");
|
|
6
8
|
return new Slower(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.20
|
|
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
|
|
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 constructor(container){\n super(container);\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 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
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ExternalInteractorBase,
|
|
1
|
+
import { ExternalInteractorBase, } from "@tsparticles/plugin-interactivity";
|
|
2
|
+
import { getDistance, isInArray } from "@tsparticles/engine";
|
|
2
3
|
import { Slow } from "./Options/Classes/Slow.js";
|
|
3
4
|
const slowMode = "slow", minRadius = 0;
|
|
4
5
|
export class Slower extends ExternalInteractorBase {
|
|
@@ -12,7 +13,7 @@ export class Slower extends ExternalInteractorBase {
|
|
|
12
13
|
particle.slow.factor = 1;
|
|
13
14
|
}
|
|
14
15
|
init() {
|
|
15
|
-
const container = this.container, slow = container.actualOptions.interactivity
|
|
16
|
+
const container = this.container, slow = container.actualOptions.interactivity?.modes.slow;
|
|
16
17
|
if (!slow) {
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
@@ -20,9 +21,9 @@ export class Slower extends ExternalInteractorBase {
|
|
|
20
21
|
}
|
|
21
22
|
interact() {
|
|
22
23
|
}
|
|
23
|
-
isEnabled(particle) {
|
|
24
|
-
const container = this.container, mouse =
|
|
25
|
-
return events
|
|
24
|
+
isEnabled(interactivityData, particle) {
|
|
25
|
+
const container = this.container, mouse = interactivityData.mouse, events = (particle?.interactivity ?? container.actualOptions.interactivity)?.events;
|
|
26
|
+
return !!events?.onHover.enable && !!mouse.position && isInArray(slowMode, events.onHover.mode);
|
|
26
27
|
}
|
|
27
28
|
loadModeOptions(options, ...sources) {
|
|
28
29
|
options.slow ??= new Slow();
|
|
@@ -30,9 +31,9 @@ export class Slower extends ExternalInteractorBase {
|
|
|
30
31
|
options.slow.load(source?.slow);
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
|
-
reset(particle) {
|
|
34
|
+
reset(interactivityData, particle) {
|
|
34
35
|
particle.slow.inRange = false;
|
|
35
|
-
const container = this.container, options = container.actualOptions, mousePos =
|
|
36
|
+
const container = this.container, options = container.actualOptions, mousePos = interactivityData.mouse.position, radius = container.retina.slowModeRadius, slowOptions = options.interactivity?.modes.slow;
|
|
36
37
|
if (!slowOptions || !radius || radius < minRadius || !mousePos) {
|
|
37
38
|
return;
|
|
38
39
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export function loadExternalSlowInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
3
|
-
engine.register(e => {
|
|
4
|
-
|
|
1
|
+
export async function loadExternalSlowInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.20");
|
|
3
|
+
await engine.register(async (e) => {
|
|
4
|
+
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
ensureInteractivityPluginLoaded(e);
|
|
6
|
+
e.addInteractor?.("externalSlow", async (container) => {
|
|
5
7
|
const { Slower } = await import("./Slower.js");
|
|
6
8
|
return new Slower(container);
|
|
7
9
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-external-slow",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.20",
|
|
4
4
|
"description": "tsParticles slow 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.20",
|
|
91
|
+
"@tsparticles/plugin-interactivity": "4.0.0-alpha.20"
|
|
91
92
|
},
|
|
92
93
|
"publishConfig": {
|
|
93
94
|
"access": "public"
|