1 | import { Container } from "./Container";
|
2 | import type { IOptions } from "../Options/Interfaces/IOptions";
|
3 | import type { RecursivePartial } from "../Types";
|
4 | import type { Particle } from "./Particle";
|
5 | import type { SingleOrMultiple } from "../Types";
|
6 | interface LoaderParams {
|
7 | element?: HTMLElement;
|
8 | index?: number;
|
9 | options?: SingleOrMultiple<RecursivePartial<IOptions>>;
|
10 | tagId?: string;
|
11 | }
|
12 | interface RemoteLoaderParams {
|
13 | element?: HTMLElement;
|
14 | index?: number;
|
15 | tagId?: string;
|
16 | url?: SingleOrMultiple<string>;
|
17 | }
|
18 | /**
|
19 | * Main class for creating the [[Container]] objects
|
20 | * @category Core
|
21 | */
|
22 | export declare class Loader {
|
23 | /**
|
24 | * All the [[Container]] objects loaded
|
25 | */
|
26 | static dom(): Container[];
|
27 | /**
|
28 | * Retrieves a [[Container]] from all the objects loaded
|
29 | * @param index the object index
|
30 | */
|
31 | static domItem(index: number): Container | undefined;
|
32 | static loadOptions(params: LoaderParams): Promise<Container | undefined>;
|
33 | static loadRemoteOptions(params: RemoteLoaderParams): Promise<Container | undefined>;
|
34 | /**
|
35 | * Loads the provided options to create a [[Container]] object.
|
36 | * @param tagId the particles container element id
|
37 | * @param options the options object to initialize the [[Container]]
|
38 | * @param index if an options array is provided, this will retrieve the exact index of that array
|
39 | */
|
40 | static load(tagId: string | SingleOrMultiple<RecursivePartial<IOptions>>, options?: SingleOrMultiple<RecursivePartial<IOptions>> | number, index?: number): Promise<Container | undefined>;
|
41 | /**
|
42 | * Loads the provided options to create a [[Container]] object.
|
43 | * @param id the particles container element id
|
44 | * @param domContainer the dom container
|
45 | * @param options the options object to initialize the [[Container]]
|
46 | * @param index if an options array is provided, this will retrieve the exact index of that array
|
47 | */
|
48 | static set(id: string | HTMLElement, domContainer: HTMLElement | SingleOrMultiple<RecursivePartial<IOptions>>, options?: SingleOrMultiple<RecursivePartial<IOptions>> | number, index?: number): Promise<Container | undefined>;
|
49 | /**
|
50 | * Loads the provided json with a GET request. The content will be used to create a [[Container]] object.
|
51 | * This method is async, so if you need a callback refer to JavaScript function `fetch`
|
52 | * @param tagId the particles container element id
|
53 | * @param jsonUrl the json path (or paths array) to use in the GET request
|
54 | * @param index the index of the paths array, if a single path is passed this value is ignored
|
55 | * @returns A Promise with the [[Container]] object created
|
56 | */
|
57 | static loadJSON(tagId: string | SingleOrMultiple<string>, jsonUrl?: SingleOrMultiple<string> | number, index?: number): Promise<Container | undefined>;
|
58 | /**
|
59 | * Loads the provided json with a GET request. The content will be used to create a [[Container]] object.
|
60 | * This method is async, so if you need a callback refer to JavaScript function `fetch`
|
61 | * @param id the particles container element id
|
62 | * @param domContainer the container used to contains the particles
|
63 | * @param jsonUrl the json path (or paths array) to use in the GET request
|
64 | * @param index the index of the paths array, if a single path is passed this value is ignored
|
65 | * @returns A Promise with the [[Container]] object created
|
66 | */
|
67 | static setJSON(id: string | HTMLElement, domContainer: HTMLElement | SingleOrMultiple<string>, jsonUrl: SingleOrMultiple<string> | (number | undefined), index?: number): Promise<Container | undefined>;
|
68 | /**
|
69 | * Adds an additional click handler to all the loaded [[Container]] objects.
|
70 | * @param callback the function called after the click event is fired
|
71 | */
|
72 | static setOnClickHandler(callback: (evt: Event, particles?: Particle[]) => void): void;
|
73 | }
|
74 | export {};
|