@tsparticles/interaction-external-push 3.0.0-alpha.1 → 3.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/README.md +25 -19
- package/browser/Options/Classes/Push.js +4 -4
- package/browser/Pusher.js +6 -7
- package/browser/index.js +5 -5
- package/browser/package.json +1 -0
- package/cjs/Options/Classes/Push.js +4 -4
- package/cjs/Pusher.js +8 -20
- package/cjs/index.js +5 -16
- package/cjs/package.json +1 -0
- package/esm/Options/Classes/Push.js +4 -4
- package/esm/Pusher.js +6 -7
- package/esm/index.js +5 -5
- package/esm/package.json +1 -0
- package/package.json +19 -6
- package/report.html +4 -4
- package/tsparticles.interaction.external.push.js +13 -14
- package/tsparticles.interaction.external.push.min.js +1 -1
- package/tsparticles.interaction.external.push.min.js.LICENSE.txt +1 -8
- package/types/Options/Classes/Push.d.ts +5 -5
- package/types/Options/Interfaces/IPush.d.ts +3 -2
- package/types/Pusher.d.ts +2 -3
- package/types/Types.d.ts +8 -4
- package/types/index.d.ts +3 -3
- package/umd/Options/Classes/Push.js +5 -5
- package/umd/Pusher.js +8 -9
- package/umd/index.js +6 -6
- package/browser/Options/Classes/PushOptions.js +0 -1
- package/cjs/Options/Classes/PushOptions.js +0 -2
- package/esm/Options/Classes/PushOptions.js +0 -1
- package/types/Options/Classes/PushOptions.d.ts +0 -7
- package/umd/Options/Classes/PushOptions.js +0 -12
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
# tsParticles External Push Interaction
|
|
4
4
|
|
|
5
|
-
[](https://www.jsdelivr.com/package/npm/@tsparticles/interaction-external-push)
|
|
6
|
+
[](https://www.npmjs.com/package/@tsparticles/interaction-external-push)
|
|
7
|
+
[](https://www.npmjs.com/package/@tsparticles/interaction-external-push) [](https://github.com/sponsors/matteobruni)
|
|
8
8
|
|
|
9
9
|
[tsParticles](https://github.com/matteobruni/tsparticles) interaction plugin for push effect around mouse or HTML
|
|
10
10
|
elements.
|
|
@@ -27,14 +27,16 @@ loadExternalPushInteraction;
|
|
|
27
27
|
Once the scripts are loaded you can set up `tsParticles` and the interaction plugin like this:
|
|
28
28
|
|
|
29
29
|
```javascript
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
30
|
+
(async () => {
|
|
31
|
+
await loadExternalPushInteraction(tsParticles);
|
|
32
|
+
|
|
33
|
+
await tsParticles.load({
|
|
34
|
+
id: "tsparticles",
|
|
35
|
+
options: {
|
|
36
|
+
/* options */
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
})();
|
|
38
40
|
```
|
|
39
41
|
|
|
40
42
|
### ESM / CommonJS
|
|
@@ -42,29 +44,33 @@ tsParticles.load({
|
|
|
42
44
|
This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
|
|
43
45
|
|
|
44
46
|
```shell
|
|
45
|
-
$ npm install tsparticles
|
|
47
|
+
$ npm install @tsparticles/interaction-external-push
|
|
46
48
|
```
|
|
47
49
|
|
|
48
50
|
or
|
|
49
51
|
|
|
50
52
|
```shell
|
|
51
|
-
$ yarn add tsparticles
|
|
53
|
+
$ yarn add @tsparticles/interaction-external-push
|
|
52
54
|
```
|
|
53
55
|
|
|
54
56
|
Then you need to import it in the app, like this:
|
|
55
57
|
|
|
56
58
|
```javascript
|
|
57
|
-
const { tsParticles } = require("tsparticles
|
|
58
|
-
const { loadExternalPushInteraction } = require("tsparticles
|
|
59
|
+
const { tsParticles } = require("@tsparticles/engine");
|
|
60
|
+
const { loadExternalPushInteraction } = require("@tsparticles/interaction-external-push");
|
|
59
61
|
|
|
60
|
-
|
|
62
|
+
(async () => {
|
|
63
|
+
await loadExternalPushInteraction(tsParticles);
|
|
64
|
+
})();
|
|
61
65
|
```
|
|
62
66
|
|
|
63
67
|
or
|
|
64
68
|
|
|
65
69
|
```javascript
|
|
66
|
-
import { tsParticles } from "tsparticles
|
|
67
|
-
import { loadExternalPushInteraction } from "tsparticles
|
|
70
|
+
import { tsParticles } from "@tsparticles/engine";
|
|
71
|
+
import { loadExternalPushInteraction } from "@tsparticles/interaction-external-push";
|
|
68
72
|
|
|
69
|
-
|
|
73
|
+
(async () => {
|
|
74
|
+
await loadExternalPushInteraction(tsParticles);
|
|
75
|
+
})();
|
|
70
76
|
```
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setRangeValue } from "@tsparticles/engine";
|
|
1
2
|
export class Push {
|
|
2
3
|
constructor() {
|
|
3
4
|
this.default = true;
|
|
@@ -8,10 +9,9 @@ export class Push {
|
|
|
8
9
|
return this.quantity;
|
|
9
10
|
}
|
|
10
11
|
set particles_nb(value) {
|
|
11
|
-
this.quantity = value;
|
|
12
|
+
this.quantity = setRangeValue(value);
|
|
12
13
|
}
|
|
13
14
|
load(data) {
|
|
14
|
-
var _a;
|
|
15
15
|
if (!data) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
@@ -24,9 +24,9 @@ export class Push {
|
|
|
24
24
|
if (!this.groups.length) {
|
|
25
25
|
this.default = true;
|
|
26
26
|
}
|
|
27
|
-
const quantity =
|
|
27
|
+
const quantity = data.quantity ?? data.particles_nb;
|
|
28
28
|
if (quantity !== undefined) {
|
|
29
|
-
this.quantity = quantity;
|
|
29
|
+
this.quantity = setRangeValue(quantity);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|
package/browser/Pusher.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ExternalInteractorBase } from "@tsparticles/engine";
|
|
2
|
-
import { Push } from "./Options/Classes/Push";
|
|
3
|
-
import { itemFromArray } from "@tsparticles/engine";
|
|
1
|
+
import { ExternalInteractorBase, getRangeValue, itemFromArray, } from "@tsparticles/engine";
|
|
2
|
+
import { Push } from "./Options/Classes/Push.js";
|
|
4
3
|
export class Pusher extends ExternalInteractorBase {
|
|
5
4
|
constructor(container) {
|
|
6
5
|
super(container);
|
|
@@ -12,12 +11,12 @@ export class Pusher extends ExternalInteractorBase {
|
|
|
12
11
|
if (!pushOptions) {
|
|
13
12
|
return;
|
|
14
13
|
}
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
14
|
+
const quantity = getRangeValue(pushOptions.quantity);
|
|
15
|
+
if (quantity <= 0) {
|
|
17
16
|
return;
|
|
18
17
|
}
|
|
19
18
|
const group = itemFromArray([undefined, ...pushOptions.groups]), groupOptions = group !== undefined ? container.actualOptions.particles.groups[group] : undefined;
|
|
20
|
-
container.particles.push(
|
|
19
|
+
container.particles.push(quantity, container.interactivity.mouse, groupOptions, group);
|
|
21
20
|
};
|
|
22
21
|
}
|
|
23
22
|
clear() {
|
|
@@ -34,7 +33,7 @@ export class Pusher extends ExternalInteractorBase {
|
|
|
34
33
|
options.push = new Push();
|
|
35
34
|
}
|
|
36
35
|
for (const source of sources) {
|
|
37
|
-
options.push.load(source
|
|
36
|
+
options.push.load(source?.push);
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
reset() {
|
package/browser/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Pusher } from "./Pusher";
|
|
2
|
-
export async function loadExternalPushInteraction(engine) {
|
|
3
|
-
await engine.addInteractor("externalPush", (container) => new Pusher(container));
|
|
1
|
+
import { Pusher } from "./Pusher.js";
|
|
2
|
+
export async function loadExternalPushInteraction(engine, refresh = true) {
|
|
3
|
+
await engine.addInteractor("externalPush", (container) => new Pusher(container), refresh);
|
|
4
4
|
}
|
|
5
|
-
export * from "./Options/Classes/Push";
|
|
6
|
-
export * from "./Options/Interfaces/IPush";
|
|
5
|
+
export * from "./Options/Classes/Push.js";
|
|
6
|
+
export * from "./Options/Interfaces/IPush.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "module" }
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Push = void 0;
|
|
4
|
+
const engine_1 = require("@tsparticles/engine");
|
|
4
5
|
class Push {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.default = true;
|
|
@@ -11,10 +12,9 @@ class Push {
|
|
|
11
12
|
return this.quantity;
|
|
12
13
|
}
|
|
13
14
|
set particles_nb(value) {
|
|
14
|
-
this.quantity = value;
|
|
15
|
+
this.quantity = (0, engine_1.setRangeValue)(value);
|
|
15
16
|
}
|
|
16
17
|
load(data) {
|
|
17
|
-
var _a;
|
|
18
18
|
if (!data) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
@@ -27,9 +27,9 @@ class Push {
|
|
|
27
27
|
if (!this.groups.length) {
|
|
28
28
|
this.default = true;
|
|
29
29
|
}
|
|
30
|
-
const quantity =
|
|
30
|
+
const quantity = data.quantity ?? data.particles_nb;
|
|
31
31
|
if (quantity !== undefined) {
|
|
32
|
-
this.quantity = quantity;
|
|
32
|
+
this.quantity = (0, engine_1.setRangeValue)(quantity);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
package/cjs/Pusher.js
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.Pusher = void 0;
|
|
13
4
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
-
const
|
|
15
|
-
const engine_2 = require("@tsparticles/engine");
|
|
5
|
+
const Push_js_1 = require("./Options/Classes/Push.js");
|
|
16
6
|
class Pusher extends engine_1.ExternalInteractorBase {
|
|
17
7
|
constructor(container) {
|
|
18
8
|
super(container);
|
|
@@ -24,31 +14,29 @@ class Pusher extends engine_1.ExternalInteractorBase {
|
|
|
24
14
|
if (!pushOptions) {
|
|
25
15
|
return;
|
|
26
16
|
}
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
17
|
+
const quantity = (0, engine_1.getRangeValue)(pushOptions.quantity);
|
|
18
|
+
if (quantity <= 0) {
|
|
29
19
|
return;
|
|
30
20
|
}
|
|
31
|
-
const group = (0,
|
|
32
|
-
container.particles.push(
|
|
21
|
+
const group = (0, engine_1.itemFromArray)([undefined, ...pushOptions.groups]), groupOptions = group !== undefined ? container.actualOptions.particles.groups[group] : undefined;
|
|
22
|
+
container.particles.push(quantity, container.interactivity.mouse, groupOptions, group);
|
|
33
23
|
};
|
|
34
24
|
}
|
|
35
25
|
clear() {
|
|
36
26
|
}
|
|
37
27
|
init() {
|
|
38
28
|
}
|
|
39
|
-
interact() {
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
});
|
|
29
|
+
async interact() {
|
|
42
30
|
}
|
|
43
31
|
isEnabled() {
|
|
44
32
|
return true;
|
|
45
33
|
}
|
|
46
34
|
loadModeOptions(options, ...sources) {
|
|
47
35
|
if (!options.push) {
|
|
48
|
-
options.push = new
|
|
36
|
+
options.push = new Push_js_1.Push();
|
|
49
37
|
}
|
|
50
38
|
for (const source of sources) {
|
|
51
|
-
options.push.load(source
|
|
39
|
+
options.push.load(source?.push);
|
|
52
40
|
}
|
|
53
41
|
}
|
|
54
42
|
reset() {
|
package/cjs/index.js
CHANGED
|
@@ -13,23 +13,12 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
17
|
exports.loadExternalPushInteraction = void 0;
|
|
27
|
-
const
|
|
28
|
-
function loadExternalPushInteraction(engine) {
|
|
29
|
-
|
|
30
|
-
yield engine.addInteractor("externalPush", (container) => new Pusher_1.Pusher(container));
|
|
31
|
-
});
|
|
18
|
+
const Pusher_js_1 = require("./Pusher.js");
|
|
19
|
+
async function loadExternalPushInteraction(engine, refresh = true) {
|
|
20
|
+
await engine.addInteractor("externalPush", (container) => new Pusher_js_1.Pusher(container), refresh);
|
|
32
21
|
}
|
|
33
22
|
exports.loadExternalPushInteraction = loadExternalPushInteraction;
|
|
34
|
-
__exportStar(require("./Options/Classes/Push"), exports);
|
|
35
|
-
__exportStar(require("./Options/Interfaces/IPush"), exports);
|
|
23
|
+
__exportStar(require("./Options/Classes/Push.js"), exports);
|
|
24
|
+
__exportStar(require("./Options/Interfaces/IPush.js"), exports);
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "commonjs" }
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setRangeValue } from "@tsparticles/engine";
|
|
1
2
|
export class Push {
|
|
2
3
|
constructor() {
|
|
3
4
|
this.default = true;
|
|
@@ -8,10 +9,9 @@ export class Push {
|
|
|
8
9
|
return this.quantity;
|
|
9
10
|
}
|
|
10
11
|
set particles_nb(value) {
|
|
11
|
-
this.quantity = value;
|
|
12
|
+
this.quantity = setRangeValue(value);
|
|
12
13
|
}
|
|
13
14
|
load(data) {
|
|
14
|
-
var _a;
|
|
15
15
|
if (!data) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
@@ -24,9 +24,9 @@ export class Push {
|
|
|
24
24
|
if (!this.groups.length) {
|
|
25
25
|
this.default = true;
|
|
26
26
|
}
|
|
27
|
-
const quantity =
|
|
27
|
+
const quantity = data.quantity ?? data.particles_nb;
|
|
28
28
|
if (quantity !== undefined) {
|
|
29
|
-
this.quantity = quantity;
|
|
29
|
+
this.quantity = setRangeValue(quantity);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|
package/esm/Pusher.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ExternalInteractorBase } from "@tsparticles/engine";
|
|
2
|
-
import { Push } from "./Options/Classes/Push";
|
|
3
|
-
import { itemFromArray } from "@tsparticles/engine";
|
|
1
|
+
import { ExternalInteractorBase, getRangeValue, itemFromArray, } from "@tsparticles/engine";
|
|
2
|
+
import { Push } from "./Options/Classes/Push.js";
|
|
4
3
|
export class Pusher extends ExternalInteractorBase {
|
|
5
4
|
constructor(container) {
|
|
6
5
|
super(container);
|
|
@@ -12,12 +11,12 @@ export class Pusher extends ExternalInteractorBase {
|
|
|
12
11
|
if (!pushOptions) {
|
|
13
12
|
return;
|
|
14
13
|
}
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
14
|
+
const quantity = getRangeValue(pushOptions.quantity);
|
|
15
|
+
if (quantity <= 0) {
|
|
17
16
|
return;
|
|
18
17
|
}
|
|
19
18
|
const group = itemFromArray([undefined, ...pushOptions.groups]), groupOptions = group !== undefined ? container.actualOptions.particles.groups[group] : undefined;
|
|
20
|
-
container.particles.push(
|
|
19
|
+
container.particles.push(quantity, container.interactivity.mouse, groupOptions, group);
|
|
21
20
|
};
|
|
22
21
|
}
|
|
23
22
|
clear() {
|
|
@@ -34,7 +33,7 @@ export class Pusher extends ExternalInteractorBase {
|
|
|
34
33
|
options.push = new Push();
|
|
35
34
|
}
|
|
36
35
|
for (const source of sources) {
|
|
37
|
-
options.push.load(source
|
|
36
|
+
options.push.load(source?.push);
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
reset() {
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Pusher } from "./Pusher";
|
|
2
|
-
export async function loadExternalPushInteraction(engine) {
|
|
3
|
-
await engine.addInteractor("externalPush", (container) => new Pusher(container));
|
|
1
|
+
import { Pusher } from "./Pusher.js";
|
|
2
|
+
export async function loadExternalPushInteraction(engine, refresh = true) {
|
|
3
|
+
await engine.addInteractor("externalPush", (container) => new Pusher(container), refresh);
|
|
4
4
|
}
|
|
5
|
-
export * from "./Options/Classes/Push";
|
|
6
|
-
export * from "./Options/Interfaces/IPush";
|
|
5
|
+
export * from "./Options/Classes/Push.js";
|
|
6
|
+
export * from "./Options/Interfaces/IPush.js";
|
package/esm/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "module" }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-external-push",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-beta.1",
|
|
4
4
|
"description": "tsParticles push external interaction",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -68,15 +68,28 @@
|
|
|
68
68
|
"bugs": {
|
|
69
69
|
"url": "https://github.com/matteobruni/tsparticles/issues"
|
|
70
70
|
},
|
|
71
|
-
"
|
|
71
|
+
"sideEffects": false,
|
|
72
72
|
"jsdelivr": "tsparticles.interaction.external.push.min.js",
|
|
73
73
|
"unpkg": "tsparticles.interaction.external.push.min.js",
|
|
74
|
+
"browser": "browser/index.js",
|
|
75
|
+
"main": "cjs/index.js",
|
|
74
76
|
"module": "esm/index.js",
|
|
75
77
|
"types": "types/index.d.ts",
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
+
"exports": {
|
|
79
|
+
".": {
|
|
80
|
+
"types": "./types/index.d.ts",
|
|
81
|
+
"browser": "./browser/index.js",
|
|
82
|
+
"import": "./esm/index.js",
|
|
83
|
+
"require": "./cjs/index.js",
|
|
84
|
+
"umd": "./umd/index.js",
|
|
85
|
+
"default": "./cjs/index.js"
|
|
86
|
+
},
|
|
87
|
+
"./package.json": "./package.json"
|
|
78
88
|
},
|
|
79
89
|
"dependencies": {
|
|
80
|
-
"@tsparticles/engine": "^3.0.0-
|
|
90
|
+
"@tsparticles/engine": "^3.0.0-beta.1"
|
|
91
|
+
},
|
|
92
|
+
"publishConfig": {
|
|
93
|
+
"access": "public"
|
|
81
94
|
}
|
|
82
|
-
}
|
|
95
|
+
}
|