@tsparticles/interaction-external-push 3.0.0-alpha.1 → 3.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/README.md +25 -19
- package/browser/Options/Classes/Push.js +4 -4
- package/browser/Pusher.js +5 -6
- package/browser/index.js +2 -2
- package/cjs/Options/Classes/Push.js +4 -4
- package/cjs/Pusher.js +6 -18
- package/cjs/index.js +2 -13
- package/esm/Options/Classes/Push.js +4 -4
- package/esm/Pusher.js +5 -6
- package/esm/index.js +2 -2
- package/package.json +6 -5
- 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 +4 -4
- package/types/Options/Interfaces/IPush.d.ts +3 -2
- package/types/Pusher.d.ts +1 -2
- package/types/Types.d.ts +6 -2
- package/types/index.d.ts +1 -1
- package/umd/Options/Classes/Push.js +5 -5
- package/umd/Pusher.js +6 -7
- package/umd/index.js +2 -2
- 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";
|
|
1
|
+
import { ExternalInteractorBase, getRangeValue, itemFromArray, } from "@tsparticles/engine";
|
|
2
2
|
import { Push } from "./Options/Classes/Push";
|
|
3
|
-
import { itemFromArray } from "@tsparticles/engine";
|
|
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
1
|
import { Pusher } from "./Pusher";
|
|
2
|
-
export async function loadExternalPushInteraction(engine) {
|
|
3
|
-
await engine.addInteractor("externalPush", (container) => new Pusher(container));
|
|
2
|
+
export async function loadExternalPushInteraction(engine, refresh = true) {
|
|
3
|
+
await engine.addInteractor("externalPush", (container) => new Pusher(container), refresh);
|
|
4
4
|
}
|
|
5
5
|
export * from "./Options/Classes/Push";
|
|
6
6
|
export * from "./Options/Interfaces/IPush";
|
|
@@ -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
5
|
const Push_1 = require("./Options/Classes/Push");
|
|
15
|
-
const engine_2 = require("@tsparticles/engine");
|
|
16
6
|
class Pusher extends engine_1.ExternalInteractorBase {
|
|
17
7
|
constructor(container) {
|
|
18
8
|
super(container);
|
|
@@ -24,21 +14,19 @@ 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;
|
|
@@ -48,7 +36,7 @@ class Pusher extends engine_1.ExternalInteractorBase {
|
|
|
48
36
|
options.push = new Push_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,22 +13,11 @@ 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
18
|
const Pusher_1 = require("./Pusher");
|
|
28
|
-
function loadExternalPushInteraction(engine) {
|
|
29
|
-
|
|
30
|
-
yield engine.addInteractor("externalPush", (container) => new Pusher_1.Pusher(container));
|
|
31
|
-
});
|
|
19
|
+
async function loadExternalPushInteraction(engine, refresh = true) {
|
|
20
|
+
await engine.addInteractor("externalPush", (container) => new Pusher_1.Pusher(container), refresh);
|
|
32
21
|
}
|
|
33
22
|
exports.loadExternalPushInteraction = loadExternalPushInteraction;
|
|
34
23
|
__exportStar(require("./Options/Classes/Push"), exports);
|
|
@@ -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";
|
|
1
|
+
import { ExternalInteractorBase, getRangeValue, itemFromArray, } from "@tsparticles/engine";
|
|
2
2
|
import { Push } from "./Options/Classes/Push";
|
|
3
|
-
import { itemFromArray } from "@tsparticles/engine";
|
|
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
1
|
import { Pusher } from "./Pusher";
|
|
2
|
-
export async function loadExternalPushInteraction(engine) {
|
|
3
|
-
await engine.addInteractor("externalPush", (container) => new Pusher(container));
|
|
2
|
+
export async function loadExternalPushInteraction(engine, refresh = true) {
|
|
3
|
+
await engine.addInteractor("externalPush", (container) => new Pusher(container), refresh);
|
|
4
4
|
}
|
|
5
5
|
export * from "./Options/Classes/Push";
|
|
6
6
|
export * from "./Options/Interfaces/IPush";
|
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.0",
|
|
4
4
|
"description": "tsParticles push external interaction",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -73,10 +73,11 @@
|
|
|
73
73
|
"unpkg": "tsparticles.interaction.external.push.min.js",
|
|
74
74
|
"module": "esm/index.js",
|
|
75
75
|
"types": "types/index.d.ts",
|
|
76
|
+
"sideEffects": false,
|
|
77
|
+
"dependencies": {
|
|
78
|
+
"@tsparticles/engine": "^3.0.0-beta.0"
|
|
79
|
+
},
|
|
76
80
|
"publishConfig": {
|
|
77
81
|
"access": "public"
|
|
78
|
-
},
|
|
79
|
-
"dependencies": {
|
|
80
|
-
"@tsparticles/engine": "^3.0.0-alpha.1"
|
|
81
82
|
}
|
|
82
|
-
}
|
|
83
|
+
}
|