@tsparticles/plugin-interactivity 4.0.0-alpha.4

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.
Files changed (171) hide show
  1. package/284.min.js +2 -0
  2. package/284.min.js.LICENSE.txt +1 -0
  3. package/721.min.js +2 -0
  4. package/721.min.js.LICENSE.txt +1 -0
  5. package/LICENSE +21 -0
  6. package/README.md +74 -0
  7. package/browser/DivType.js +5 -0
  8. package/browser/ExternalInteractorBase.js +7 -0
  9. package/browser/IExternalInteractor.js +1 -0
  10. package/browser/IInteractivityData.js +1 -0
  11. package/browser/IInteractor.js +1 -0
  12. package/browser/IMouseData.js +1 -0
  13. package/browser/IParticlesInteractor.js +1 -0
  14. package/browser/InteractionManager.js +202 -0
  15. package/browser/InteractivityConstants.js +1 -0
  16. package/browser/InteractivityDetect.js +6 -0
  17. package/browser/InteractivityEventListeners.js +235 -0
  18. package/browser/InteractivityPlugin.js +48 -0
  19. package/browser/InteractivityPluginInstance.js +52 -0
  20. package/browser/InteractorType.js +5 -0
  21. package/browser/Options/Classes/Events/ClickEvent.js +18 -0
  22. package/browser/Options/Classes/Events/DivEvent.js +27 -0
  23. package/browser/Options/Classes/Events/Events.js +26 -0
  24. package/browser/Options/Classes/Events/HoverEvent.js +18 -0
  25. package/browser/Options/Classes/Interactivity.js +22 -0
  26. package/browser/Options/Classes/Modes/Modes.js +25 -0
  27. package/browser/Options/Interfaces/Events/IClickEvent.js +1 -0
  28. package/browser/Options/Interfaces/Events/IDivEvent.js +1 -0
  29. package/browser/Options/Interfaces/Events/IEvents.js +1 -0
  30. package/browser/Options/Interfaces/Events/IHoverEvent.js +1 -0
  31. package/browser/Options/Interfaces/IInteractivity.js +1 -0
  32. package/browser/Options/Interfaces/Modes/IModeDiv.js +1 -0
  33. package/browser/Options/Interfaces/Modes/IModes.js +1 -0
  34. package/browser/ParticlesInteractorBase.js +7 -0
  35. package/browser/index.js +38 -0
  36. package/browser/package.json +1 -0
  37. package/browser/types.js +1 -0
  38. package/browser/utils.js +32 -0
  39. package/cjs/DivType.js +5 -0
  40. package/cjs/ExternalInteractorBase.js +7 -0
  41. package/cjs/IExternalInteractor.js +1 -0
  42. package/cjs/IInteractivityData.js +1 -0
  43. package/cjs/IInteractor.js +1 -0
  44. package/cjs/IMouseData.js +1 -0
  45. package/cjs/IParticlesInteractor.js +1 -0
  46. package/cjs/InteractionManager.js +202 -0
  47. package/cjs/InteractivityConstants.js +1 -0
  48. package/cjs/InteractivityDetect.js +6 -0
  49. package/cjs/InteractivityEventListeners.js +235 -0
  50. package/cjs/InteractivityPlugin.js +48 -0
  51. package/cjs/InteractivityPluginInstance.js +52 -0
  52. package/cjs/InteractorType.js +5 -0
  53. package/cjs/Options/Classes/Events/ClickEvent.js +18 -0
  54. package/cjs/Options/Classes/Events/DivEvent.js +27 -0
  55. package/cjs/Options/Classes/Events/Events.js +26 -0
  56. package/cjs/Options/Classes/Events/HoverEvent.js +18 -0
  57. package/cjs/Options/Classes/Interactivity.js +22 -0
  58. package/cjs/Options/Classes/Modes/Modes.js +25 -0
  59. package/cjs/Options/Interfaces/Events/IClickEvent.js +1 -0
  60. package/cjs/Options/Interfaces/Events/IDivEvent.js +1 -0
  61. package/cjs/Options/Interfaces/Events/IEvents.js +1 -0
  62. package/cjs/Options/Interfaces/Events/IHoverEvent.js +1 -0
  63. package/cjs/Options/Interfaces/IInteractivity.js +1 -0
  64. package/cjs/Options/Interfaces/Modes/IModeDiv.js +1 -0
  65. package/cjs/Options/Interfaces/Modes/IModes.js +1 -0
  66. package/cjs/ParticlesInteractorBase.js +7 -0
  67. package/cjs/index.js +38 -0
  68. package/cjs/package.json +1 -0
  69. package/cjs/types.js +1 -0
  70. package/cjs/utils.js +32 -0
  71. package/dist_browser_InteractivityPluginInstance_js.js +50 -0
  72. package/dist_browser_InteractivityPlugin_js.js +70 -0
  73. package/esm/DivType.js +5 -0
  74. package/esm/ExternalInteractorBase.js +7 -0
  75. package/esm/IExternalInteractor.js +1 -0
  76. package/esm/IInteractivityData.js +1 -0
  77. package/esm/IInteractor.js +1 -0
  78. package/esm/IMouseData.js +1 -0
  79. package/esm/IParticlesInteractor.js +1 -0
  80. package/esm/InteractionManager.js +202 -0
  81. package/esm/InteractivityConstants.js +1 -0
  82. package/esm/InteractivityDetect.js +6 -0
  83. package/esm/InteractivityEventListeners.js +235 -0
  84. package/esm/InteractivityPlugin.js +48 -0
  85. package/esm/InteractivityPluginInstance.js +52 -0
  86. package/esm/InteractorType.js +5 -0
  87. package/esm/Options/Classes/Events/ClickEvent.js +18 -0
  88. package/esm/Options/Classes/Events/DivEvent.js +27 -0
  89. package/esm/Options/Classes/Events/Events.js +26 -0
  90. package/esm/Options/Classes/Events/HoverEvent.js +18 -0
  91. package/esm/Options/Classes/Interactivity.js +22 -0
  92. package/esm/Options/Classes/Modes/Modes.js +25 -0
  93. package/esm/Options/Interfaces/Events/IClickEvent.js +1 -0
  94. package/esm/Options/Interfaces/Events/IDivEvent.js +1 -0
  95. package/esm/Options/Interfaces/Events/IEvents.js +1 -0
  96. package/esm/Options/Interfaces/Events/IHoverEvent.js +1 -0
  97. package/esm/Options/Interfaces/IInteractivity.js +1 -0
  98. package/esm/Options/Interfaces/Modes/IModeDiv.js +1 -0
  99. package/esm/Options/Interfaces/Modes/IModes.js +1 -0
  100. package/esm/ParticlesInteractorBase.js +7 -0
  101. package/esm/index.js +38 -0
  102. package/esm/package.json +1 -0
  103. package/esm/types.js +1 -0
  104. package/esm/utils.js +32 -0
  105. package/package.json +95 -0
  106. package/report.html +40 -0
  107. package/tsparticles.plugin.interactivity.js +395 -0
  108. package/tsparticles.plugin.interactivity.min.js +2 -0
  109. package/tsparticles.plugin.interactivity.min.js.LICENSE.txt +1 -0
  110. package/types/DivType.d.ts +4 -0
  111. package/types/ExternalInteractorBase.d.ts +15 -0
  112. package/types/IExternalInteractor.d.ts +11 -0
  113. package/types/IInteractivityData.d.ts +6 -0
  114. package/types/IInteractor.d.ts +12 -0
  115. package/types/IMouseData.d.ts +9 -0
  116. package/types/IParticlesInteractor.d.ts +7 -0
  117. package/types/InteractionManager.d.ts +27 -0
  118. package/types/InteractivityConstants.d.ts +1 -0
  119. package/types/InteractivityDetect.d.ts +5 -0
  120. package/types/InteractivityEventListeners.d.ts +23 -0
  121. package/types/InteractivityPlugin.d.ts +11 -0
  122. package/types/InteractivityPluginInstance.d.ts +20 -0
  123. package/types/InteractorType.d.ts +4 -0
  124. package/types/Options/Classes/Events/ClickEvent.d.ts +8 -0
  125. package/types/Options/Classes/Events/DivEvent.d.ts +11 -0
  126. package/types/Options/Classes/Events/Events.d.ts +12 -0
  127. package/types/Options/Classes/Events/HoverEvent.d.ts +8 -0
  128. package/types/Options/Classes/Interactivity.d.ts +14 -0
  129. package/types/Options/Classes/Modes/Modes.d.ts +10 -0
  130. package/types/Options/Interfaces/Events/IClickEvent.d.ts +5 -0
  131. package/types/Options/Interfaces/Events/IDivEvent.d.ts +8 -0
  132. package/types/Options/Interfaces/Events/IEvents.d.ts +9 -0
  133. package/types/Options/Interfaces/Events/IHoverEvent.d.ts +5 -0
  134. package/types/Options/Interfaces/IInteractivity.d.ts +9 -0
  135. package/types/Options/Interfaces/Modes/IModeDiv.d.ts +4 -0
  136. package/types/Options/Interfaces/Modes/IModes.d.ts +1 -0
  137. package/types/ParticlesInteractorBase.d.ts +15 -0
  138. package/types/index.d.ts +19 -0
  139. package/types/types.d.ts +32 -0
  140. package/types/utils.d.ts +7 -0
  141. package/umd/DivType.js +18 -0
  142. package/umd/ExternalInteractorBase.js +21 -0
  143. package/umd/IExternalInteractor.js +12 -0
  144. package/umd/IInteractivityData.js +12 -0
  145. package/umd/IInteractor.js +12 -0
  146. package/umd/IMouseData.js +12 -0
  147. package/umd/IParticlesInteractor.js +12 -0
  148. package/umd/InteractionManager.js +216 -0
  149. package/umd/InteractivityConstants.js +14 -0
  150. package/umd/InteractivityDetect.js +19 -0
  151. package/umd/InteractivityEventListeners.js +249 -0
  152. package/umd/InteractivityPlugin.js +96 -0
  153. package/umd/InteractivityPluginInstance.js +66 -0
  154. package/umd/InteractorType.js +18 -0
  155. package/umd/Options/Classes/Events/ClickEvent.js +32 -0
  156. package/umd/Options/Classes/Events/DivEvent.js +41 -0
  157. package/umd/Options/Classes/Events/Events.js +40 -0
  158. package/umd/Options/Classes/Events/HoverEvent.js +32 -0
  159. package/umd/Options/Classes/Interactivity.js +36 -0
  160. package/umd/Options/Classes/Modes/Modes.js +39 -0
  161. package/umd/Options/Interfaces/Events/IClickEvent.js +12 -0
  162. package/umd/Options/Interfaces/Events/IDivEvent.js +12 -0
  163. package/umd/Options/Interfaces/Events/IEvents.js +12 -0
  164. package/umd/Options/Interfaces/Events/IHoverEvent.js +12 -0
  165. package/umd/Options/Interfaces/IInteractivity.js +12 -0
  166. package/umd/Options/Interfaces/Modes/IModeDiv.js +12 -0
  167. package/umd/Options/Interfaces/Modes/IModes.js +12 -0
  168. package/umd/ParticlesInteractorBase.js +21 -0
  169. package/umd/index.js +88 -0
  170. package/umd/types.js +12 -0
  171. package/umd/utils.js +48 -0
@@ -0,0 +1,11 @@
1
+ import { type IOptionLoader, type RecursivePartial, type SingleOrMultiple } from "@tsparticles/engine";
2
+ import { DivType } from "../../../DivType.js";
3
+ import type { IDivEvent } from "../../Interfaces/Events/IDivEvent.js";
4
+ export declare class DivEvent implements IDivEvent, IOptionLoader<IDivEvent> {
5
+ enable: boolean;
6
+ mode: SingleOrMultiple<string>;
7
+ selectors: SingleOrMultiple<string>;
8
+ type: DivType | keyof typeof DivType;
9
+ constructor();
10
+ load(data?: RecursivePartial<IDivEvent>): void;
11
+ }
@@ -0,0 +1,12 @@
1
+ import { type IOptionLoader, type RecursivePartial, type SingleOrMultiple } from "@tsparticles/engine";
2
+ import { ClickEvent } from "./ClickEvent.js";
3
+ import { DivEvent } from "./DivEvent.js";
4
+ import { HoverEvent } from "./HoverEvent.js";
5
+ import type { IEvents } from "../../Interfaces/Events/IEvents.js";
6
+ export declare class Events implements IEvents, IOptionLoader<IEvents> {
7
+ readonly onClick: ClickEvent;
8
+ onDiv: SingleOrMultiple<DivEvent>;
9
+ readonly onHover: HoverEvent;
10
+ constructor();
11
+ load(data?: RecursivePartial<IEvents>): void;
12
+ }
@@ -0,0 +1,8 @@
1
+ import { type IOptionLoader, type RecursivePartial, type SingleOrMultiple } from "@tsparticles/engine";
2
+ import type { IHoverEvent } from "../../Interfaces/Events/IHoverEvent.js";
3
+ export declare class HoverEvent implements IHoverEvent, IOptionLoader<IHoverEvent> {
4
+ enable: boolean;
5
+ mode: SingleOrMultiple<string>;
6
+ constructor();
7
+ load(data?: RecursivePartial<IHoverEvent>): void;
8
+ }
@@ -0,0 +1,14 @@
1
+ import { type Container, type IOptionLoader, type RecursivePartial } from "@tsparticles/engine";
2
+ import { Events } from "./Events/Events.js";
3
+ import type { IInteractivity } from "../Interfaces/IInteractivity.js";
4
+ import { InteractivityDetect } from "../../InteractivityDetect.js";
5
+ import type { InteractivityEngine } from "../../types.js";
6
+ import { Modes } from "./Modes/Modes.js";
7
+ export declare class Interactivity implements IInteractivity, IOptionLoader<IInteractivity> {
8
+ [name: string]: unknown;
9
+ detectsOn: InteractivityDetect | keyof typeof InteractivityDetect;
10
+ readonly events: Events;
11
+ readonly modes: Modes;
12
+ constructor(engine: InteractivityEngine, container?: Container);
13
+ load(data?: RecursivePartial<IInteractivity>): void;
14
+ }
@@ -0,0 +1,10 @@
1
+ import { type Container, type IOptionLoader, type RecursivePartial } from "@tsparticles/engine";
2
+ import type { IModes } from "../../Interfaces/Modes/IModes.js";
3
+ import type { InteractivityEngine } from "../../../types.js";
4
+ export declare class Modes implements IModes, IOptionLoader<IModes> {
5
+ [name: string]: unknown;
6
+ private readonly _container;
7
+ private readonly _engine;
8
+ constructor(engine: InteractivityEngine, container?: Container);
9
+ load(data?: RecursivePartial<IModes>): void;
10
+ }
@@ -0,0 +1,5 @@
1
+ import type { SingleOrMultiple } from "@tsparticles/engine";
2
+ export interface IClickEvent {
3
+ enable: boolean;
4
+ mode: SingleOrMultiple<string>;
5
+ }
@@ -0,0 +1,8 @@
1
+ import type { DivType } from "../../../DivType.js";
2
+ import type { SingleOrMultiple } from "@tsparticles/engine";
3
+ export interface IDivEvent {
4
+ enable: boolean;
5
+ mode: SingleOrMultiple<string>;
6
+ selectors: SingleOrMultiple<string>;
7
+ type: DivType | keyof typeof DivType;
8
+ }
@@ -0,0 +1,9 @@
1
+ import type { IClickEvent } from "./IClickEvent.js";
2
+ import type { IDivEvent } from "./IDivEvent.js";
3
+ import type { IHoverEvent } from "./IHoverEvent.js";
4
+ import type { SingleOrMultiple } from "@tsparticles/engine";
5
+ export interface IEvents {
6
+ onClick: IClickEvent;
7
+ onDiv: SingleOrMultiple<IDivEvent>;
8
+ onHover: IHoverEvent;
9
+ }
@@ -0,0 +1,5 @@
1
+ import type { SingleOrMultiple } from "@tsparticles/engine";
2
+ export interface IHoverEvent {
3
+ enable: boolean;
4
+ mode: SingleOrMultiple<string>;
5
+ }
@@ -0,0 +1,9 @@
1
+ import type { IEvents } from "./Events/IEvents.js";
2
+ import type { IModes } from "./Modes/IModes.js";
3
+ import type { InteractivityDetect } from "../../InteractivityDetect.js";
4
+ export interface IInteractivity {
5
+ [name: string]: unknown;
6
+ detectsOn: InteractivityDetect | keyof typeof InteractivityDetect;
7
+ events: IEvents;
8
+ modes: IModes;
9
+ }
@@ -0,0 +1,4 @@
1
+ import type { SingleOrMultiple } from "@tsparticles/engine";
2
+ export interface IModeDiv {
3
+ selectors: SingleOrMultiple<string>;
4
+ }
@@ -0,0 +1 @@
1
+ export type IModes = Record<string, unknown>;
@@ -0,0 +1,15 @@
1
+ import type { InteractivityContainer, InteractivityParticle } from "./types.js";
2
+ import { type IDelta } from "@tsparticles/engine";
3
+ import type { IInteractivityData } from "./IInteractivityData.js";
4
+ import type { IParticlesInteractor } from "./IParticlesInteractor.js";
5
+ import { InteractorType } from "./InteractorType.js";
6
+ export declare abstract class ParticlesInteractorBase<TContainer extends InteractivityContainer = InteractivityContainer, TParticle extends InteractivityParticle = InteractivityParticle> implements IParticlesInteractor<TParticle> {
7
+ type: InteractorType;
8
+ protected readonly container: TContainer;
9
+ protected constructor(container: TContainer);
10
+ abstract clear(particle: TParticle, delta: IDelta): void;
11
+ abstract init(): void;
12
+ abstract interact(particle: TParticle, interactivityData: IInteractivityData, delta: IDelta): void;
13
+ abstract isEnabled(particle: TParticle, interactivityData: IInteractivityData): boolean;
14
+ abstract reset(interactivityData: IInteractivityData, particle: TParticle): void;
15
+ }
@@ -0,0 +1,19 @@
1
+ import { type Engine } from "@tsparticles/engine";
2
+ export declare function loadInteractivityPlugin(engine: Engine): void;
3
+ export * from "./DivType.js";
4
+ export * from "./ExternalInteractorBase.js";
5
+ export type * from "./IExternalInteractor.js";
6
+ export type * from "./IInteractivityData.js";
7
+ export type * from "./IInteractor.js";
8
+ export * from "./InteractivityConstants.js";
9
+ export * from "./InteractivityDetect.js";
10
+ export * from "./InteractorType.js";
11
+ export type * from "./IParticlesInteractor.js";
12
+ export * from "./ParticlesInteractorBase.js";
13
+ export type * from "./types.js";
14
+ export * from "./utils.js";
15
+ export type * from "./Options/Interfaces/Events/IDivEvent.js";
16
+ export type * from "./Options/Interfaces/Modes/IModes.js";
17
+ export type * from "./Options/Interfaces/Modes/IModeDiv.js";
18
+ export * from "./Options/Classes/Events/DivEvent.js";
19
+ export * from "./Options/Classes/Modes/Modes.js";
@@ -0,0 +1,32 @@
1
+ import type { Container, Engine, GenericInitializer, IOptions, IParticlesOptions, Options, Particle, ParticlesOptions, RecursivePartial } from "@tsparticles/engine";
2
+ import type { IInteractivity } from "./Options/Interfaces/IInteractivity.js";
3
+ import type { IInteractor } from "./IInteractor.js";
4
+ import type { Interactivity } from "./Options/Classes/Interactivity.js";
5
+ export type IInteractivityOptions = IOptions & {
6
+ interactivity?: IInteractivity;
7
+ };
8
+ export type InteractivityOptions = Options & {
9
+ interactivity?: Interactivity;
10
+ };
11
+ export type InteractivityContainer = Container & {
12
+ actualOptions: InteractivityOptions;
13
+ addClickHandler?: (callback: (evt: Event, particles?: Particle[]) => void) => void;
14
+ };
15
+ export type InteractivityParticle = Particle & {
16
+ interactivity?: Interactivity;
17
+ options: InteractivityParticlesOptions;
18
+ };
19
+ export type IInteractivityParticlesOptions = IParticlesOptions & {
20
+ interactivity?: RecursivePartial<IInteractivity>;
21
+ };
22
+ export type InteractivityParticlesOptions = RecursivePartial<ParticlesOptions> & {
23
+ interactivity?: RecursivePartial<IInteractivity>;
24
+ };
25
+ export type InteractorInitializer = GenericInitializer<IInteractor>;
26
+ export type InteractivityEngine = Engine & {
27
+ addInteractor?: (name: string, interactorInitializer: InteractorInitializer) => void;
28
+ getInteractors?: (container: Container, force?: boolean) => Promise<IInteractor[]>;
29
+ interactors?: Map<Container, IInteractor[]>;
30
+ interactorsInitializers?: Map<string, InteractorInitializer>;
31
+ setOnClickHandler?: (callback: (e: Event, particles?: Particle[]) => void) => void;
32
+ };
@@ -0,0 +1,7 @@
1
+ import { type SingleOrMultiple } from "@tsparticles/engine";
2
+ import type { DivEvent } from "./Options/Classes/Events/DivEvent.js";
3
+ import type { IModeDiv } from "./Options/Interfaces/Modes/IModeDiv.js";
4
+ export declare function isDivModeEnabled(mode: string, divs: SingleOrMultiple<DivEvent>): boolean;
5
+ export declare function divModeExecute(mode: string, divs: SingleOrMultiple<DivEvent>, callback: (id: string, div: DivEvent) => void): void;
6
+ export declare function singleDivModeExecute(div: DivEvent, callback: (selector: string, div: DivEvent) => void): void;
7
+ export declare function divMode<T extends IModeDiv>(divs?: SingleOrMultiple<T>, element?: HTMLElement): T | undefined;
package/umd/DivType.js ADDED
@@ -0,0 +1,18 @@
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
+ exports.DivType = void 0;
13
+ var DivType;
14
+ (function (DivType) {
15
+ DivType["circle"] = "circle";
16
+ DivType["rectangle"] = "rectangle";
17
+ })(DivType || (exports.DivType = DivType = {}));
18
+ });
@@ -0,0 +1,21 @@
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", "./InteractorType.js"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ExternalInteractorBase = void 0;
13
+ const InteractorType_js_1 = require("./InteractorType.js");
14
+ class ExternalInteractorBase {
15
+ constructor(container) {
16
+ this.type = InteractorType_js_1.InteractorType.external;
17
+ this.container = container;
18
+ }
19
+ }
20
+ exports.ExternalInteractorBase = ExternalInteractorBase;
21
+ });
@@ -0,0 +1,12 @@
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
+ });
@@ -0,0 +1,12 @@
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
+ });
@@ -0,0 +1,12 @@
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
+ });
@@ -0,0 +1,12 @@
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
+ });
@@ -0,0 +1,12 @@
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
+ });
@@ -0,0 +1,216 @@
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", "@tsparticles/engine", "./InteractivityConstants.js", "./InteractivityEventListeners.js", "./InteractorType.js"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.InteractionManager = void 0;
13
+ const engine_1 = require("@tsparticles/engine");
14
+ const InteractivityConstants_js_1 = require("./InteractivityConstants.js");
15
+ const InteractivityEventListeners_js_1 = require("./InteractivityEventListeners.js");
16
+ const InteractorType_js_1 = require("./InteractorType.js");
17
+ class InteractionManager {
18
+ constructor(engine, container) {
19
+ this.container = container;
20
+ this._intersectionManager = entries => {
21
+ const { container } = this;
22
+ if (container.destroyed || !container.actualOptions.pauseOnOutsideViewport) {
23
+ return;
24
+ }
25
+ for (const entry of entries) {
26
+ if (entry.target !== this.interactivityData.element) {
27
+ continue;
28
+ }
29
+ if (entry.isIntersecting) {
30
+ container.play();
31
+ }
32
+ else {
33
+ container.pause();
34
+ }
35
+ }
36
+ };
37
+ this._engine = engine;
38
+ this._interactors = [];
39
+ this._externalInteractors = [];
40
+ this._particleInteractors = [];
41
+ this._clickHandlers = new Map();
42
+ this._eventListeners = new InteractivityEventListeners_js_1.InteractivityEventListeners(container, this);
43
+ this.interactivityData = {
44
+ mouse: {
45
+ clicking: false,
46
+ inside: false,
47
+ },
48
+ };
49
+ this._intersectionObserver = (0, engine_1.safeIntersectionObserver)(entries => {
50
+ this._intersectionManager(entries);
51
+ });
52
+ }
53
+ addClickHandler(callback) {
54
+ const { container, interactivityData } = this;
55
+ if (container.destroyed) {
56
+ return;
57
+ }
58
+ const el = interactivityData.element;
59
+ if (!el) {
60
+ return;
61
+ }
62
+ const clickOrTouchHandler = (e, pos, radius) => {
63
+ if (container.destroyed) {
64
+ return;
65
+ }
66
+ const pxRatio = container.retina.pixelRatio, posRetina = {
67
+ x: pos.x * pxRatio,
68
+ y: pos.y * pxRatio,
69
+ }, particles = container.particles.quadTree.queryCircle(posRetina, radius * pxRatio);
70
+ callback(e, particles);
71
+ }, clickHandler = (e) => {
72
+ if (container.destroyed) {
73
+ return;
74
+ }
75
+ const mouseEvent = e, pos = {
76
+ x: mouseEvent.offsetX,
77
+ y: mouseEvent.offsetY,
78
+ };
79
+ clickOrTouchHandler(e, pos, engine_1.clickRadius);
80
+ }, touchStartHandler = () => {
81
+ if (container.destroyed) {
82
+ return;
83
+ }
84
+ touched = true;
85
+ touchMoved = false;
86
+ }, touchMoveHandler = () => {
87
+ if (container.destroyed) {
88
+ return;
89
+ }
90
+ touchMoved = true;
91
+ }, touchEndHandler = (e) => {
92
+ if (container.destroyed) {
93
+ return;
94
+ }
95
+ if (touched && !touchMoved) {
96
+ const touchEvent = e, lastTouch = touchEvent.touches[touchEvent.touches.length - engine_1.touchEndLengthOffset];
97
+ if (!lastTouch) {
98
+ return;
99
+ }
100
+ const element = container.canvas.element, canvasRect = element ? element.getBoundingClientRect() : undefined, pos = {
101
+ x: lastTouch.clientX - (canvasRect ? canvasRect.left : engine_1.minCoordinate),
102
+ y: lastTouch.clientY - (canvasRect ? canvasRect.top : engine_1.minCoordinate),
103
+ };
104
+ clickOrTouchHandler(e, pos, Math.max(lastTouch.radiusX, lastTouch.radiusY));
105
+ }
106
+ touched = false;
107
+ touchMoved = false;
108
+ }, touchCancelHandler = () => {
109
+ if (container.destroyed) {
110
+ return;
111
+ }
112
+ touched = false;
113
+ touchMoved = false;
114
+ };
115
+ let touched = false, touchMoved = false;
116
+ this._clickHandlers.set(InteractivityConstants_js_1.clickEvent, clickHandler);
117
+ this._clickHandlers.set(InteractivityConstants_js_1.touchStartEvent, touchStartHandler);
118
+ this._clickHandlers.set(InteractivityConstants_js_1.touchMoveEvent, touchMoveHandler);
119
+ this._clickHandlers.set(InteractivityConstants_js_1.touchEndEvent, touchEndHandler);
120
+ this._clickHandlers.set(InteractivityConstants_js_1.touchCancelEvent, touchCancelHandler);
121
+ for (const [key, handler] of this._clickHandlers) {
122
+ el.addEventListener(key, handler);
123
+ }
124
+ }
125
+ addListeners() {
126
+ this._eventListeners.addListeners();
127
+ }
128
+ clearClickHandlers() {
129
+ const { container, interactivityData } = this;
130
+ if (container.destroyed) {
131
+ return;
132
+ }
133
+ for (const [key, handler] of this._clickHandlers) {
134
+ interactivityData.element?.removeEventListener(key, handler);
135
+ }
136
+ this._clickHandlers.clear();
137
+ }
138
+ externalInteract(delta) {
139
+ for (const interactor of this._externalInteractors) {
140
+ const { interactivityData } = this;
141
+ if (interactor.isEnabled(interactivityData)) {
142
+ interactor.interact(interactivityData, delta);
143
+ }
144
+ }
145
+ }
146
+ handleClickMode(mode) {
147
+ if (this.container.destroyed) {
148
+ return;
149
+ }
150
+ const { interactivityData } = this;
151
+ for (const interactor of this._externalInteractors) {
152
+ interactor.handleClickMode?.(mode, interactivityData);
153
+ }
154
+ }
155
+ async init() {
156
+ const interactors = await this._engine.getInteractors?.(this.container, true);
157
+ if (!interactors) {
158
+ return;
159
+ }
160
+ this._interactors = interactors;
161
+ this._externalInteractors = [];
162
+ this._particleInteractors = [];
163
+ for (const interactor of this._interactors) {
164
+ switch (interactor.type) {
165
+ case InteractorType_js_1.InteractorType.external:
166
+ this._externalInteractors.push(interactor);
167
+ break;
168
+ case InteractorType_js_1.InteractorType.particles:
169
+ this._particleInteractors.push(interactor);
170
+ break;
171
+ }
172
+ interactor.init();
173
+ }
174
+ }
175
+ particlesInteract(particle, delta) {
176
+ const { interactivityData } = this;
177
+ for (const interactor of this._externalInteractors) {
178
+ interactor.clear(particle, delta);
179
+ }
180
+ for (const interactor of this._particleInteractors) {
181
+ if (interactor.isEnabled(particle, interactivityData)) {
182
+ interactor.interact(particle, interactivityData, delta);
183
+ }
184
+ }
185
+ }
186
+ removeListeners() {
187
+ this._eventListeners.removeListeners();
188
+ }
189
+ reset(particle) {
190
+ const { interactivityData } = this;
191
+ for (const interactor of this._externalInteractors) {
192
+ if (interactor.isEnabled(interactivityData)) {
193
+ interactor.reset(interactivityData, particle);
194
+ }
195
+ }
196
+ for (const interactor of this._particleInteractors) {
197
+ if (interactor.isEnabled(particle, interactivityData)) {
198
+ interactor.reset(interactivityData, particle);
199
+ }
200
+ }
201
+ }
202
+ startObserving() {
203
+ const { interactivityData } = this;
204
+ if (interactivityData.element instanceof HTMLElement && this._intersectionObserver) {
205
+ this._intersectionObserver.observe(interactivityData.element);
206
+ }
207
+ }
208
+ stopObserving() {
209
+ const { interactivityData } = this;
210
+ if (interactivityData.element instanceof HTMLElement && this._intersectionObserver) {
211
+ this._intersectionObserver.unobserve(interactivityData.element);
212
+ }
213
+ }
214
+ }
215
+ exports.InteractionManager = InteractionManager;
216
+ });
@@ -0,0 +1,14 @@
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
+ exports.touchCancelEvent = exports.touchMoveEvent = exports.touchEndEvent = exports.touchStartEvent = exports.mouseMoveEvent = exports.mouseOutEvent = exports.mouseLeaveEvent = exports.mouseUpEvent = exports.mouseDownEvent = exports.clickEvent = void 0;
13
+ exports.clickEvent = "click", exports.mouseDownEvent = "pointerdown", exports.mouseUpEvent = "pointerup", exports.mouseLeaveEvent = "pointerleave", exports.mouseOutEvent = "pointerout", exports.mouseMoveEvent = "pointermove", exports.touchStartEvent = "touchstart", exports.touchEndEvent = "touchend", exports.touchMoveEvent = "touchmove", exports.touchCancelEvent = "touchcancel";
14
+ });
@@ -0,0 +1,19 @@
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
+ exports.InteractivityDetect = void 0;
13
+ var InteractivityDetect;
14
+ (function (InteractivityDetect) {
15
+ InteractivityDetect["canvas"] = "canvas";
16
+ InteractivityDetect["parent"] = "parent";
17
+ InteractivityDetect["window"] = "window";
18
+ })(InteractivityDetect || (exports.InteractivityDetect = InteractivityDetect = {}));
19
+ });