-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
68 lines (53 loc) · 1.72 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// @path-json can be an object or an array, the first will be loaded directly, and the object from the array will be randomly selected
/* tsParticles.loadJSON(@dom-id, @path-json, @callback (optional)); */
tsParticles
.loadJSON("tsparticles", "presets/default.json")
.then(container => {
console.log("callback - tsparticles config loaded");
})
.catch(error => {
console.error(error);
});
//or
/* tsParticles.load(@dom-id, @options); */
tsParticles.load("tsparticles", {
/* options here */
});
//or
/* tsParticles.loadFromArray(@dom-id, @options, @index (optional)); */
tsParticles.loadFromArray("tsparticles", [
{
/* options here */
},
{
/* other options here */
},
]);
//random object
tsParticles.loadFromArray(
"tsparticles",
[
{
/* options here */
},
{
/* other options here */
},
],
1
); //the second one
// Important! If the index is not in range 0...<array.length, the index will be ignored.
// after initialization this can be used.
/* tsParticles.setOnClickHandler(@callback); */
/* this will be fired from all particles loaded */
tsParticles.setOnClickHandler((event, particles) => {
/* custom on click handler */
});
// now you can control the animations too, it's possible to pause and resume the animations
// these methods don't change the config so you're safe with all your configurations
// domItem(0) returns the first tsParticles instance loaded in the dom
const particles = tsParticles.domItem(0);
// play will start the animations, if the move is not enabled it won't enable it, it just updates the frame
particles.play();
// pause will stop the animations
particles.pause();