@tsparticles/interaction-external-push 3.0.0-alpha.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Matteo Bruni
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,70 @@
1
+ [![banner](https://particles.js.org/images/banner2.png)](https://particles.js.org)
2
+
3
+ # tsParticles External Push Interaction
4
+
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/tsparticles-interaction-external-push/badge)](https://www.jsdelivr.com/package/npm/tsparticles-interaction-external-push)
6
+ [![npmjs](https://badge.fury.io/js/tsparticles-interaction-external-push.svg)](https://www.npmjs.com/package/tsparticles-interaction-external-push)
7
+ [![npmjs](https://img.shields.io/npm/dt/tsparticles-interaction-external-push)](https://www.npmjs.com/package/tsparticles-interaction-external-push) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
8
+
9
+ [tsParticles](https://github.com/matteobruni/tsparticles) interaction plugin for push effect around mouse or HTML
10
+ elements.
11
+
12
+ ## How to use it
13
+
14
+ ### CDN / Vanilla JS / jQuery
15
+
16
+ The CDN/Vanilla version JS has one required file in vanilla configuration:
17
+
18
+ Including the `tsparticles.interaction.external.push.min.js` file will export the function to load the interaction
19
+ plugin:
20
+
21
+ ```javascript
22
+ loadExternalPushInteraction;
23
+ ```
24
+
25
+ ### Usage
26
+
27
+ Once the scripts are loaded you can set up `tsParticles` and the interaction plugin like this:
28
+
29
+ ```javascript
30
+ loadExternalPushInteraction(tsParticles);
31
+
32
+ tsParticles.load({
33
+ id: "tsparticles",
34
+ options: {
35
+ /* options */
36
+ },
37
+ });
38
+ ```
39
+
40
+ ### ESM / CommonJS
41
+
42
+ This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
43
+
44
+ ```shell
45
+ $ npm install tsparticles-interaction-external-push
46
+ ```
47
+
48
+ or
49
+
50
+ ```shell
51
+ $ yarn add tsparticles-interaction-external-push
52
+ ```
53
+
54
+ Then you need to import it in the app, like this:
55
+
56
+ ```javascript
57
+ const { tsParticles } = require("tsparticles-engine");
58
+ const { loadExternalPushInteraction } = require("tsparticles-interaction-external-push");
59
+
60
+ loadExternalPushInteraction(tsParticles);
61
+ ```
62
+
63
+ or
64
+
65
+ ```javascript
66
+ import { tsParticles } from "tsparticles-engine";
67
+ import { loadExternalPushInteraction } from "tsparticles-interaction-external-push";
68
+
69
+ loadExternalPushInteraction(tsParticles);
70
+ ```
@@ -0,0 +1,32 @@
1
+ export class Push {
2
+ constructor() {
3
+ this.default = true;
4
+ this.groups = [];
5
+ this.quantity = 4;
6
+ }
7
+ get particles_nb() {
8
+ return this.quantity;
9
+ }
10
+ set particles_nb(value) {
11
+ this.quantity = value;
12
+ }
13
+ load(data) {
14
+ var _a;
15
+ if (!data) {
16
+ return;
17
+ }
18
+ if (data.default !== undefined) {
19
+ this.default = data.default;
20
+ }
21
+ if (data.groups !== undefined) {
22
+ this.groups = data.groups.map((t) => t);
23
+ }
24
+ if (!this.groups.length) {
25
+ this.default = true;
26
+ }
27
+ const quantity = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb;
28
+ if (quantity !== undefined) {
29
+ this.quantity = quantity;
30
+ }
31
+ }
32
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,42 @@
1
+ import { ExternalInteractorBase } from "@tsparticles/engine";
2
+ import { Push } from "./Options/Classes/Push";
3
+ import { itemFromArray } from "@tsparticles/engine";
4
+ export class Pusher extends ExternalInteractorBase {
5
+ constructor(container) {
6
+ super(container);
7
+ this.handleClickMode = (mode) => {
8
+ if (mode !== "push") {
9
+ return;
10
+ }
11
+ const container = this.container, options = container.actualOptions, pushOptions = options.interactivity.modes.push;
12
+ if (!pushOptions) {
13
+ return;
14
+ }
15
+ const pushNb = pushOptions.quantity;
16
+ if (pushNb <= 0) {
17
+ return;
18
+ }
19
+ const group = itemFromArray([undefined, ...pushOptions.groups]), groupOptions = group !== undefined ? container.actualOptions.particles.groups[group] : undefined;
20
+ container.particles.push(pushNb, container.interactivity.mouse, groupOptions, group);
21
+ };
22
+ }
23
+ clear() {
24
+ }
25
+ init() {
26
+ }
27
+ async interact() {
28
+ }
29
+ isEnabled() {
30
+ return true;
31
+ }
32
+ loadModeOptions(options, ...sources) {
33
+ if (!options.push) {
34
+ options.push = new Push();
35
+ }
36
+ for (const source of sources) {
37
+ options.push.load(source === null || source === void 0 ? void 0 : source.push);
38
+ }
39
+ }
40
+ reset() {
41
+ }
42
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { Pusher } from "./Pusher";
2
+ export async function loadExternalPushInteraction(engine) {
3
+ await engine.addInteractor("externalPush", (container) => new Pusher(container));
4
+ }
5
+ export * from "./Options/Classes/Push";
6
+ export * from "./Options/Interfaces/IPush";
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Push = void 0;
4
+ class Push {
5
+ constructor() {
6
+ this.default = true;
7
+ this.groups = [];
8
+ this.quantity = 4;
9
+ }
10
+ get particles_nb() {
11
+ return this.quantity;
12
+ }
13
+ set particles_nb(value) {
14
+ this.quantity = value;
15
+ }
16
+ load(data) {
17
+ var _a;
18
+ if (!data) {
19
+ return;
20
+ }
21
+ if (data.default !== undefined) {
22
+ this.default = data.default;
23
+ }
24
+ if (data.groups !== undefined) {
25
+ this.groups = data.groups.map((t) => t);
26
+ }
27
+ if (!this.groups.length) {
28
+ this.default = true;
29
+ }
30
+ const quantity = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb;
31
+ if (quantity !== undefined) {
32
+ this.quantity = quantity;
33
+ }
34
+ }
35
+ }
36
+ exports.Push = Push;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/cjs/Pusher.js ADDED
@@ -0,0 +1,57 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Pusher = void 0;
13
+ const engine_1 = require("@tsparticles/engine");
14
+ const Push_1 = require("./Options/Classes/Push");
15
+ const engine_2 = require("@tsparticles/engine");
16
+ class Pusher extends engine_1.ExternalInteractorBase {
17
+ constructor(container) {
18
+ super(container);
19
+ this.handleClickMode = (mode) => {
20
+ if (mode !== "push") {
21
+ return;
22
+ }
23
+ const container = this.container, options = container.actualOptions, pushOptions = options.interactivity.modes.push;
24
+ if (!pushOptions) {
25
+ return;
26
+ }
27
+ const pushNb = pushOptions.quantity;
28
+ if (pushNb <= 0) {
29
+ return;
30
+ }
31
+ const group = (0, engine_2.itemFromArray)([undefined, ...pushOptions.groups]), groupOptions = group !== undefined ? container.actualOptions.particles.groups[group] : undefined;
32
+ container.particles.push(pushNb, container.interactivity.mouse, groupOptions, group);
33
+ };
34
+ }
35
+ clear() {
36
+ }
37
+ init() {
38
+ }
39
+ interact() {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ });
42
+ }
43
+ isEnabled() {
44
+ return true;
45
+ }
46
+ loadModeOptions(options, ...sources) {
47
+ if (!options.push) {
48
+ options.push = new Push_1.Push();
49
+ }
50
+ for (const source of sources) {
51
+ options.push.load(source === null || source === void 0 ? void 0 : source.push);
52
+ }
53
+ }
54
+ reset() {
55
+ }
56
+ }
57
+ exports.Pusher = Pusher;
package/cjs/Types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/cjs/index.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.loadExternalPushInteraction = void 0;
27
+ const Pusher_1 = require("./Pusher");
28
+ function loadExternalPushInteraction(engine) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ yield engine.addInteractor("externalPush", (container) => new Pusher_1.Pusher(container));
31
+ });
32
+ }
33
+ exports.loadExternalPushInteraction = loadExternalPushInteraction;
34
+ __exportStar(require("./Options/Classes/Push"), exports);
35
+ __exportStar(require("./Options/Interfaces/IPush"), exports);
@@ -0,0 +1,32 @@
1
+ export class Push {
2
+ constructor() {
3
+ this.default = true;
4
+ this.groups = [];
5
+ this.quantity = 4;
6
+ }
7
+ get particles_nb() {
8
+ return this.quantity;
9
+ }
10
+ set particles_nb(value) {
11
+ this.quantity = value;
12
+ }
13
+ load(data) {
14
+ var _a;
15
+ if (!data) {
16
+ return;
17
+ }
18
+ if (data.default !== undefined) {
19
+ this.default = data.default;
20
+ }
21
+ if (data.groups !== undefined) {
22
+ this.groups = data.groups.map((t) => t);
23
+ }
24
+ if (!this.groups.length) {
25
+ this.default = true;
26
+ }
27
+ const quantity = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb;
28
+ if (quantity !== undefined) {
29
+ this.quantity = quantity;
30
+ }
31
+ }
32
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/esm/Pusher.js ADDED
@@ -0,0 +1,42 @@
1
+ import { ExternalInteractorBase } from "@tsparticles/engine";
2
+ import { Push } from "./Options/Classes/Push";
3
+ import { itemFromArray } from "@tsparticles/engine";
4
+ export class Pusher extends ExternalInteractorBase {
5
+ constructor(container) {
6
+ super(container);
7
+ this.handleClickMode = (mode) => {
8
+ if (mode !== "push") {
9
+ return;
10
+ }
11
+ const container = this.container, options = container.actualOptions, pushOptions = options.interactivity.modes.push;
12
+ if (!pushOptions) {
13
+ return;
14
+ }
15
+ const pushNb = pushOptions.quantity;
16
+ if (pushNb <= 0) {
17
+ return;
18
+ }
19
+ const group = itemFromArray([undefined, ...pushOptions.groups]), groupOptions = group !== undefined ? container.actualOptions.particles.groups[group] : undefined;
20
+ container.particles.push(pushNb, container.interactivity.mouse, groupOptions, group);
21
+ };
22
+ }
23
+ clear() {
24
+ }
25
+ init() {
26
+ }
27
+ async interact() {
28
+ }
29
+ isEnabled() {
30
+ return true;
31
+ }
32
+ loadModeOptions(options, ...sources) {
33
+ if (!options.push) {
34
+ options.push = new Push();
35
+ }
36
+ for (const source of sources) {
37
+ options.push.load(source === null || source === void 0 ? void 0 : source.push);
38
+ }
39
+ }
40
+ reset() {
41
+ }
42
+ }
package/esm/Types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/esm/index.js ADDED
@@ -0,0 +1,6 @@
1
+ import { Pusher } from "./Pusher";
2
+ export async function loadExternalPushInteraction(engine) {
3
+ await engine.addInteractor("externalPush", (container) => new Pusher(container));
4
+ }
5
+ export * from "./Options/Classes/Push";
6
+ export * from "./Options/Interfaces/IPush";
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "@tsparticles/interaction-external-push",
3
+ "version": "3.0.0-alpha.0",
4
+ "description": "tsParticles push external interaction",
5
+ "homepage": "https://particles.js.org",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/matteobruni/tsparticles.git",
9
+ "directory": "interactions/external/push"
10
+ },
11
+ "keywords": [
12
+ "front-end",
13
+ "frontend",
14
+ "tsparticles",
15
+ "particles.js",
16
+ "particlesjs",
17
+ "particles",
18
+ "particle",
19
+ "canvas",
20
+ "jsparticles",
21
+ "xparticles",
22
+ "particles-js",
23
+ "particles-bg",
24
+ "particles-bg-vue",
25
+ "particles-ts",
26
+ "particles.ts",
27
+ "react-particles-js",
28
+ "react-particles.js",
29
+ "react-particles",
30
+ "react",
31
+ "reactjs",
32
+ "vue-particles",
33
+ "ngx-particles",
34
+ "angular-particles",
35
+ "particleground",
36
+ "vue",
37
+ "vuejs",
38
+ "preact",
39
+ "preactjs",
40
+ "jquery",
41
+ "angularjs",
42
+ "angular",
43
+ "typescript",
44
+ "javascript",
45
+ "animation",
46
+ "web",
47
+ "html5",
48
+ "web-design",
49
+ "webdesign",
50
+ "css",
51
+ "html",
52
+ "css3",
53
+ "animated",
54
+ "background",
55
+ "confetti",
56
+ "canvas",
57
+ "fireworks",
58
+ "fireworks-js",
59
+ "confetti-js",
60
+ "confettijs",
61
+ "fireworksjs",
62
+ "canvas-confetti",
63
+ "@tsparticles/plugin",
64
+ "@tsparticles/interaction"
65
+ ],
66
+ "author": "Matteo Bruni <matteo.bruni@me.com>",
67
+ "license": "MIT",
68
+ "bugs": {
69
+ "url": "https://github.com/matteobruni/tsparticles/issues"
70
+ },
71
+ "main": "cjs/index.js",
72
+ "jsdelivr": "tsparticles.interaction.external.push.min.js",
73
+ "unpkg": "tsparticles.interaction.external.push.min.js",
74
+ "module": "esm/index.js",
75
+ "types": "types/index.d.ts",
76
+ "publishConfig": {
77
+ "access": "public"
78
+ },
79
+ "dependencies": {
80
+ "@tsparticles/engine": "^3.0.0-alpha.0"
81
+ }
82
+ }