1 | const initPjs = (main) => {
|
2 | /**
|
3 | * Loads the provided options to create a [[Container]] object.
|
4 | * @deprecated this method is obsolete, please use the new tsParticles.load
|
5 | * @param tagId the particles container element id
|
6 | * @param options the options object to initialize the [[Container]]
|
7 | */
|
8 | const particlesJS = (tagId, options) => {
|
9 | return main.load(tagId, options);
|
10 | };
|
11 | /**
|
12 | * Loads the provided json with a GET request.
|
13 | * The content will be used to create a [[Container]] object.
|
14 | * @deprecated this method is obsolete, please use the new tsParticles.loadJSON
|
15 | * @param tagId the particles container element id
|
16 | * @param pathConfigJson the json path to use in the GET request
|
17 | * @param callback called after the [[Container]] is loaded and it will be passed as a parameter
|
18 | */
|
19 | particlesJS.load = (tagId, pathConfigJson, callback) => {
|
20 | main.loadJSON(tagId, pathConfigJson)
|
21 | .then((container) => {
|
22 | if (container) {
|
23 | callback(container);
|
24 | }
|
25 | })
|
26 | .catch(() => {
|
27 | callback(undefined);
|
28 | });
|
29 | };
|
30 | /**
|
31 | * Adds an additional click handler to all the loaded [[Container]] objects.
|
32 | * @deprecated this method is obsolete, please use the new tsParticles.setOnClickHandler
|
33 | * @param callback the function called after the click event is fired
|
34 | */
|
35 | particlesJS.setOnClickHandler = (callback) => {
|
36 | main.setOnClickHandler(callback);
|
37 | };
|
38 | /**
|
39 | * All the [[Container]] objects loaded
|
40 | * @deprecated this method is obsolete, please use the new tsParticles.dom
|
41 | */
|
42 | const pJSDom = main.dom();
|
43 | return { particlesJS, pJSDom };
|
44 | };
|
45 | export { initPjs };
|