@tsparticles/interaction-external-remove 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.
@@ -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
- * v3.0.0-alpha.1
7
+ * v3.0.0-beta.0
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -91,13 +91,14 @@ __webpack_require__.r(__webpack_exports__);
91
91
 
92
92
  // EXPORTS
93
93
  __webpack_require__.d(__webpack_exports__, {
94
- "Remove": () => (/* reexport */ Remove),
95
- "loadExternalRemoveInteraction": () => (/* binding */ loadExternalRemoveInteraction)
94
+ Remove: () => (/* reexport */ Remove),
95
+ loadExternalRemoveInteraction: () => (/* binding */ loadExternalRemoveInteraction)
96
96
  });
97
97
 
98
98
  // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
99
99
  var engine_root_window_ = __webpack_require__(533);
100
100
  ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Remove.js
101
+
101
102
  class Remove {
102
103
  constructor() {
103
104
  this.quantity = 2;
@@ -106,16 +107,15 @@ class Remove {
106
107
  return this.quantity;
107
108
  }
108
109
  set particles_nb(value) {
109
- this.quantity = value;
110
+ this.quantity = (0,engine_root_window_.setRangeValue)(value);
110
111
  }
111
112
  load(data) {
112
- var _a;
113
113
  if (!data) {
114
114
  return;
115
115
  }
116
- const quantity = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb;
116
+ const quantity = data.quantity ?? data.particles_nb;
117
117
  if (quantity !== undefined) {
118
- this.quantity = quantity;
118
+ this.quantity = (0,engine_root_window_.setRangeValue)(quantity);
119
119
  }
120
120
  }
121
121
  }
@@ -131,7 +131,7 @@ class Remover extends engine_root_window_.ExternalInteractorBase {
131
131
  if (!options.interactivity.modes.remove || mode !== "remove") {
132
132
  return;
133
133
  }
134
- const removeNb = options.interactivity.modes.remove.quantity;
134
+ const removeNb = (0,engine_root_window_.getRangeValue)(options.interactivity.modes.remove.quantity);
135
135
  container.particles.removeQuantity(removeNb);
136
136
  };
137
137
  }
@@ -146,15 +146,15 @@ class Remover extends engine_root_window_.ExternalInteractorBase {
146
146
  options.remove = new Remove();
147
147
  }
148
148
  for (const source of sources) {
149
- options.remove.load(source === null || source === void 0 ? void 0 : source.remove);
149
+ options.remove.load(source?.remove);
150
150
  }
151
151
  }
152
152
  reset() {}
153
153
  }
154
154
  ;// CONCATENATED MODULE: ./dist/browser/index.js
155
155
 
156
- function loadExternalRemoveInteraction(engine) {
157
- engine.addInteractor("externalRemove", container => new Remover(container));
156
+ async function loadExternalRemoveInteraction(engine, refresh = true) {
157
+ await engine.addInteractor("externalRemove", container => new Remover(container), refresh);
158
158
  }
159
159
 
160
160
 
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.interaction.external.remove.min.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{Remove:()=>t,loadExternalRemoveInteraction:()=>i});var e=o(533);class t{constructor(){this.quantity=2}get particles_nb(){return this.quantity}set particles_nb(e){this.quantity=e}load(e){var t;if(!e)return;const r=null!==(t=e.quantity)&&void 0!==t?t:e.particles_nb;void 0!==r&&(this.quantity=r)}}class r extends e.ExternalInteractorBase{constructor(e){super(e),this.handleClickMode=e=>{const t=this.container,r=t.actualOptions;if(!r.interactivity.modes.remove||"remove"!==e)return;const o=r.interactivity.modes.remove.quantity;t.particles.removeQuantity(o)}}clear(){}init(){}async interact(){}isEnabled(){return!0}loadModeOptions(e,...r){e.remove||(e.remove=new t);for(const t of r)e.remove.load(null==t?void 0:t.remove)}reset(){}}function i(e){e.addInteractor("externalRemove",(e=>new r(e)))}})(),n})()));
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{Remove:()=>t,loadExternalRemoveInteraction:()=>i});var e=o(533);class t{constructor(){this.quantity=2}get particles_nb(){return this.quantity}set particles_nb(t){this.quantity=(0,e.setRangeValue)(t)}load(t){if(!t)return;const r=t.quantity??t.particles_nb;void 0!==r&&(this.quantity=(0,e.setRangeValue)(r))}}class r extends e.ExternalInteractorBase{constructor(t){super(t),this.handleClickMode=t=>{const r=this.container,o=r.actualOptions;if(!o.interactivity.modes.remove||"remove"!==t)return;const n=(0,e.getRangeValue)(o.interactivity.modes.remove.quantity);r.particles.removeQuantity(n)}}clear(){}init(){}async interact(){}isEnabled(){return!0}loadModeOptions(e,...r){e.remove||(e.remove=new t);for(const t of r)e.remove.load(t?.remove)}reset(){}}async function i(e,t=!0){await e.addInteractor("externalRemove",(e=>new r(e)),t)}})(),n})()));
@@ -1,8 +1 @@
1
- /*!
2
- * Author : Matteo Bruni
3
- * MIT license: https://opensource.org/licenses/MIT
4
- * Demo / Generator : https://particles.js.org/
5
- * GitHub : https://www.github.com/matteobruni/tsparticles
6
- * How to use? : Check the GitHub README
7
- * v3.0.0-alpha.1
8
- */
1
+ /*! tsParticles Remove External Interaction v3.0.0-beta.0 by Matteo Bruni */
@@ -1,9 +1,9 @@
1
- import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
1
+ import { type IOptionLoader, type RangeValue, type RecursivePartial } from "@tsparticles/engine";
2
2
  import type { IRemove } from "../Interfaces/IRemove";
3
3
  export declare class Remove implements IRemove, IOptionLoader<IRemove> {
4
- quantity: number;
4
+ quantity: RangeValue;
5
5
  constructor();
6
- get particles_nb(): number;
7
- set particles_nb(value: number);
6
+ get particles_nb(): RangeValue;
7
+ set particles_nb(value: RangeValue);
8
8
  load(data?: RecursivePartial<IRemove>): void;
9
9
  }
@@ -1,4 +1,5 @@
1
+ import type { RangeValue } from "@tsparticles/engine";
1
2
  export interface IRemove {
2
- particles_nb: number;
3
- quantity: number;
3
+ particles_nb: RangeValue;
4
+ quantity: RangeValue;
4
5
  }
@@ -1,5 +1,4 @@
1
- import { ExternalInteractorBase } from "@tsparticles/engine";
2
- import type { IModes, Modes, RecursivePartial } from "@tsparticles/engine";
1
+ import { ExternalInteractorBase, type IModes, type Modes, type RecursivePartial } from "@tsparticles/engine";
3
2
  import type { IRemoveMode, RemoveContainer, RemoveMode } from "./Types";
4
3
  export declare class Remover extends ExternalInteractorBase<RemoveContainer> {
5
4
  handleClickMode: (mode: string) => void;
package/types/Types.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import type { Container } from "@tsparticles/engine";
1
+ import type { Container, Options } from "@tsparticles/engine";
2
2
  import type { IRemove } from "./Options/Interfaces/IRemove";
3
3
  import type { Remove } from "./Options/Classes/Remove";
4
- import type { RemoveOptions } from "./Options/Classes/RemoveOptions";
5
4
  export type IRemoveMode = {
6
5
  remove: IRemove;
7
6
  };
@@ -11,3 +10,8 @@ export type RemoveMode = {
11
10
  export type RemoveContainer = Container & {
12
11
  actualOptions: RemoveOptions;
13
12
  };
13
+ export type RemoveOptions = Options & {
14
+ interactivity: {
15
+ modes: RemoveMode;
16
+ };
17
+ };
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import type { Engine } from "@tsparticles/engine";
2
- export declare function loadExternalRemoveInteraction(engine: Engine): void;
2
+ export declare function loadExternalRemoveInteraction(engine: Engine, refresh?: boolean): Promise<void>;
3
3
  export * from "./Options/Classes/Remove";
4
4
  export * from "./Options/Interfaces/IRemove";
@@ -4,12 +4,13 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
7
+ define(["require", "exports", "@tsparticles/engine"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Remove = void 0;
13
+ const engine_1 = require("@tsparticles/engine");
13
14
  class Remove {
14
15
  constructor() {
15
16
  this.quantity = 2;
@@ -18,16 +19,15 @@
18
19
  return this.quantity;
19
20
  }
20
21
  set particles_nb(value) {
21
- this.quantity = value;
22
+ this.quantity = (0, engine_1.setRangeValue)(value);
22
23
  }
23
24
  load(data) {
24
- var _a;
25
25
  if (!data) {
26
26
  return;
27
27
  }
28
- const quantity = (_a = data.quantity) !== null && _a !== void 0 ? _a : data.particles_nb;
28
+ const quantity = data.quantity ?? data.particles_nb;
29
29
  if (quantity !== undefined) {
30
- this.quantity = quantity;
30
+ this.quantity = (0, engine_1.setRangeValue)(quantity);
31
31
  }
32
32
  }
33
33
  }
package/umd/Remover.js CHANGED
@@ -20,7 +20,7 @@
20
20
  if (!options.interactivity.modes.remove || mode !== "remove") {
21
21
  return;
22
22
  }
23
- const removeNb = options.interactivity.modes.remove.quantity;
23
+ const removeNb = (0, engine_1.getRangeValue)(options.interactivity.modes.remove.quantity);
24
24
  container.particles.removeQuantity(removeNb);
25
25
  };
26
26
  }
@@ -38,7 +38,7 @@
38
38
  options.remove = new Remove_1.Remove();
39
39
  }
40
40
  for (const source of sources) {
41
- options.remove.load(source === null || source === void 0 ? void 0 : source.remove);
41
+ options.remove.load(source?.remove);
42
42
  }
43
43
  }
44
44
  reset() {
package/umd/index.js CHANGED
@@ -25,8 +25,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.loadExternalRemoveInteraction = void 0;
27
27
  const Remover_1 = require("./Remover");
28
- function loadExternalRemoveInteraction(engine) {
29
- engine.addInteractor("externalRemove", (container) => new Remover_1.Remover(container));
28
+ async function loadExternalRemoveInteraction(engine, refresh = true) {
29
+ await engine.addInteractor("externalRemove", (container) => new Remover_1.Remover(container), refresh);
30
30
  }
31
31
  exports.loadExternalRemoveInteraction = loadExternalRemoveInteraction;
32
32
  __exportStar(require("./Options/Classes/Remove"), exports);
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- import type { Options } from "@tsparticles/engine";
2
- import type { RemoveMode } from "../../Types";
3
- export type RemoveOptions = Options & {
4
- interactivity: {
5
- modes: RemoveMode;
6
- };
7
- };
@@ -1,12 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- });