@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 CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  # tsParticles External Push Interaction
4
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)
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
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
- loadExternalPushInteraction(tsParticles);
31
-
32
- tsParticles.load({
33
- id: "tsparticles",
34
- options: {
35
- /* options */
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-interaction-external-push
47
+ $ npm install @tsparticles/interaction-external-push
46
48
  ```
47
49
 
48
50
  or
49
51
 
50
52
  ```shell
51
- $ yarn add tsparticles-interaction-external-push
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-engine");
58
- const { loadExternalPushInteraction } = require("tsparticles-interaction-external-push");
59
+ const { tsParticles } = require("@tsparticles/engine");
60
+ const { loadExternalPushInteraction } = require("@tsparticles/interaction-external-push");
59
61
 
60
- loadExternalPushInteraction(tsParticles);
62
+ (async () => {
63
+ await loadExternalPushInteraction(tsParticles);
64
+ })();
61
65
  ```
62
66
 
63
67
  or
64
68
 
65
69
  ```javascript
66
- import { tsParticles } from "tsparticles-engine";
67
- import { loadExternalPushInteraction } from "tsparticles-interaction-external-push";
70
+ import { tsParticles } from "@tsparticles/engine";
71
+ import { loadExternalPushInteraction } from "@tsparticles/interaction-external-push";
68
72
 
69
- loadExternalPushInteraction(tsParticles);
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 = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb;
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 pushNb = pushOptions.quantity;
16
- if (pushNb <= 0) {
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(pushNb, container.interactivity.mouse, groupOptions, group);
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 === null || source === void 0 ? void 0 : source.push);
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 = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb;
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 pushNb = pushOptions.quantity;
28
- if (pushNb <= 0) {
17
+ const quantity = (0, engine_1.getRangeValue)(pushOptions.quantity);
18
+ if (quantity <= 0) {
29
19
  return;
30
20
  }
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);
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 === null || source === void 0 ? void 0 : source.push);
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
- return __awaiter(this, void 0, void 0, function* () {
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 = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb;
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 pushNb = pushOptions.quantity;
16
- if (pushNb <= 0) {
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(pushNb, container.interactivity.mouse, groupOptions, group);
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 === null || source === void 0 ? void 0 : source.push);
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-alpha.1",
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
+ }