@tsparticles/pjs 3.0.0-alpha.1 → 3.0.0-beta.5
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +46 -8
- package/browser/VincentGarreau/particles.js +271 -0
- package/browser/bundle.js +2 -2
- package/browser/index.js +7 -20
- package/browser/marcbruederlin/Particles.js +83 -0
- package/browser/package.json +1 -0
- package/cjs/VincentGarreau/particles.js +274 -0
- package/cjs/bundle.js +3 -2
- package/cjs/index.js +7 -20
- package/cjs/marcbruederlin/Particles.js +87 -0
- package/cjs/package.json +1 -0
- package/esm/VincentGarreau/particles.js +271 -0
- package/esm/bundle.js +2 -2
- package/esm/index.js +7 -20
- package/esm/marcbruederlin/Particles.js +83 -0
- package/esm/package.json +1 -0
- package/package.json +36 -13
- package/report.html +5 -5
- package/tsparticles.pjs.bundle.js +2596 -2312
- package/tsparticles.pjs.bundle.min.js +1 -1
- package/tsparticles.pjs.bundle.min.js.LICENSE.txt +1 -8
- package/tsparticles.pjs.js +396 -12
- package/tsparticles.pjs.min.js +1 -1
- package/tsparticles.pjs.min.js.LICENSE.txt +1 -8
- package/types/VincentGarreau/IParticlesJS.d.ts +117 -0
- package/types/VincentGarreau/particles.d.ts +7 -0
- package/types/bundle.d.ts +2 -2
- package/types/index.d.ts +11 -2
- package/types/marcbruederlin/Particles.d.ts +23 -0
- package/umd/VincentGarreau/particles.js +284 -0
- package/umd/bundle.js +3 -2
- package/umd/index.js +8 -21
- package/umd/marcbruederlin/Particles.js +97 -0
- package/types/IParticlesJS.d.ts +0 -6
- /package/browser/{IParticlesJS.js → VincentGarreau/IParticlesJS.js} +0 -0
- /package/cjs/{IParticlesJS.js → VincentGarreau/IParticlesJS.js} +0 -0
- /package/esm/{IParticlesJS.js → VincentGarreau/IParticlesJS.js} +0 -0
- /package/umd/{IParticlesJS.js → VincentGarreau/IParticlesJS.js} +0 -0
@@ -0,0 +1,284 @@
|
|
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"], factory);
|
8
|
+
}
|
9
|
+
})(function (require, exports) {
|
10
|
+
"use strict";
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.initParticlesJS = void 0;
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
14
|
+
const defaultPjsOptions = {
|
15
|
+
particles: {
|
16
|
+
number: {
|
17
|
+
value: 400,
|
18
|
+
density: {
|
19
|
+
enable: true,
|
20
|
+
value_area: 800,
|
21
|
+
},
|
22
|
+
},
|
23
|
+
color: {
|
24
|
+
value: "#fff",
|
25
|
+
},
|
26
|
+
shape: {
|
27
|
+
type: "circle",
|
28
|
+
stroke: {
|
29
|
+
width: 0,
|
30
|
+
color: "#ff0000",
|
31
|
+
},
|
32
|
+
polygon: {
|
33
|
+
nb_sides: 5,
|
34
|
+
},
|
35
|
+
image: {
|
36
|
+
src: "",
|
37
|
+
width: 100,
|
38
|
+
height: 100,
|
39
|
+
},
|
40
|
+
},
|
41
|
+
opacity: {
|
42
|
+
value: 1,
|
43
|
+
random: false,
|
44
|
+
anim: {
|
45
|
+
enable: false,
|
46
|
+
speed: 2,
|
47
|
+
opacity_min: 0,
|
48
|
+
sync: false,
|
49
|
+
},
|
50
|
+
},
|
51
|
+
size: {
|
52
|
+
value: 20,
|
53
|
+
random: false,
|
54
|
+
anim: {
|
55
|
+
enable: false,
|
56
|
+
speed: 20,
|
57
|
+
size_min: 0,
|
58
|
+
sync: false,
|
59
|
+
},
|
60
|
+
},
|
61
|
+
line_linked: {
|
62
|
+
enable: true,
|
63
|
+
distance: 100,
|
64
|
+
color: "#fff",
|
65
|
+
opacity: 1,
|
66
|
+
width: 1,
|
67
|
+
},
|
68
|
+
move: {
|
69
|
+
enable: true,
|
70
|
+
speed: 2,
|
71
|
+
direction: "none",
|
72
|
+
random: false,
|
73
|
+
straight: false,
|
74
|
+
out_mode: "out",
|
75
|
+
bounce: false,
|
76
|
+
attract: {
|
77
|
+
enable: false,
|
78
|
+
rotateX: 3000,
|
79
|
+
rotateY: 3000,
|
80
|
+
},
|
81
|
+
},
|
82
|
+
},
|
83
|
+
interactivity: {
|
84
|
+
detect_on: "canvas",
|
85
|
+
events: {
|
86
|
+
onhover: {
|
87
|
+
enable: true,
|
88
|
+
mode: "grab",
|
89
|
+
},
|
90
|
+
onclick: {
|
91
|
+
enable: true,
|
92
|
+
mode: "push",
|
93
|
+
},
|
94
|
+
resize: true,
|
95
|
+
},
|
96
|
+
modes: {
|
97
|
+
grab: {
|
98
|
+
distance: 100,
|
99
|
+
line_linked: {
|
100
|
+
opacity: 1,
|
101
|
+
},
|
102
|
+
},
|
103
|
+
bubble: {
|
104
|
+
distance: 200,
|
105
|
+
size: 80,
|
106
|
+
duration: 0.4,
|
107
|
+
opacity: 1,
|
108
|
+
speed: 3,
|
109
|
+
},
|
110
|
+
repulse: {
|
111
|
+
distance: 200,
|
112
|
+
duration: 0.4,
|
113
|
+
},
|
114
|
+
push: {
|
115
|
+
particles_nb: 4,
|
116
|
+
},
|
117
|
+
remove: {
|
118
|
+
particles_nb: 2,
|
119
|
+
},
|
120
|
+
},
|
121
|
+
},
|
122
|
+
retina_detect: false,
|
123
|
+
};
|
124
|
+
const initParticlesJS = (engine) => {
|
125
|
+
const particlesJS = (tagId, options) => {
|
126
|
+
const fixedOptions = (0, engine_1.deepExtend)(defaultPjsOptions, options);
|
127
|
+
return engine.load({
|
128
|
+
id: tagId,
|
129
|
+
options: {
|
130
|
+
fullScreen: {
|
131
|
+
enable: false,
|
132
|
+
},
|
133
|
+
detectRetina: fixedOptions.retina_detect,
|
134
|
+
smooth: true,
|
135
|
+
interactivity: {
|
136
|
+
detectsOn: fixedOptions.interactivity.detect_on,
|
137
|
+
events: {
|
138
|
+
onHover: {
|
139
|
+
enable: fixedOptions.interactivity.events.onhover.enable,
|
140
|
+
mode: fixedOptions.interactivity.events.onhover.mode,
|
141
|
+
},
|
142
|
+
onClick: {
|
143
|
+
enable: fixedOptions.interactivity.events.onclick.enable,
|
144
|
+
mode: fixedOptions.interactivity.events.onclick.mode,
|
145
|
+
},
|
146
|
+
resize: {
|
147
|
+
enable: fixedOptions.interactivity.events.resize,
|
148
|
+
},
|
149
|
+
},
|
150
|
+
modes: {
|
151
|
+
grab: {
|
152
|
+
distance: fixedOptions.interactivity.modes.grab.distance,
|
153
|
+
links: {
|
154
|
+
opacity: fixedOptions.interactivity.modes.grab.line_linked.opacity,
|
155
|
+
},
|
156
|
+
},
|
157
|
+
bubble: {
|
158
|
+
distance: fixedOptions.interactivity.modes.bubble.distance,
|
159
|
+
size: fixedOptions.interactivity.modes.bubble.size,
|
160
|
+
duration: fixedOptions.interactivity.modes.bubble.duration,
|
161
|
+
opacity: fixedOptions.interactivity.modes.bubble.opacity,
|
162
|
+
speed: fixedOptions.interactivity.modes.bubble.speed,
|
163
|
+
},
|
164
|
+
repulse: {
|
165
|
+
distance: fixedOptions.interactivity.modes.repulse.distance,
|
166
|
+
duration: fixedOptions.interactivity.modes.repulse.duration,
|
167
|
+
},
|
168
|
+
push: {
|
169
|
+
quantity: fixedOptions.interactivity.modes.push.particles_nb,
|
170
|
+
},
|
171
|
+
remove: {
|
172
|
+
quantity: fixedOptions.interactivity.modes.remove.particles_nb,
|
173
|
+
},
|
174
|
+
},
|
175
|
+
},
|
176
|
+
particles: {
|
177
|
+
collisions: {
|
178
|
+
enable: fixedOptions.particles.move.bounce,
|
179
|
+
},
|
180
|
+
number: {
|
181
|
+
value: fixedOptions.particles.number.value,
|
182
|
+
density: {
|
183
|
+
enable: fixedOptions.particles.number.density.enable,
|
184
|
+
width: fixedOptions.particles.number.density.value_area,
|
185
|
+
},
|
186
|
+
},
|
187
|
+
color: {
|
188
|
+
value: fixedOptions.particles.color.value,
|
189
|
+
},
|
190
|
+
stroke: {
|
191
|
+
width: fixedOptions.particles.shape.stroke.width,
|
192
|
+
color: {
|
193
|
+
value: fixedOptions.particles.shape.stroke.color,
|
194
|
+
},
|
195
|
+
},
|
196
|
+
shape: {
|
197
|
+
type: fixedOptions.particles.shape.type,
|
198
|
+
options: {
|
199
|
+
polygon: {
|
200
|
+
sides: fixedOptions.particles.shape.polygon.nb_sides,
|
201
|
+
},
|
202
|
+
image: {
|
203
|
+
src: fixedOptions.particles.shape.image.src,
|
204
|
+
width: fixedOptions.particles.shape.image.width,
|
205
|
+
height: fixedOptions.particles.shape.image.height,
|
206
|
+
},
|
207
|
+
},
|
208
|
+
},
|
209
|
+
opacity: {
|
210
|
+
value: fixedOptions.particles.opacity.random
|
211
|
+
? {
|
212
|
+
min: fixedOptions.particles.opacity.anim.enable
|
213
|
+
? fixedOptions.particles.opacity.anim.opacity_min
|
214
|
+
: 0,
|
215
|
+
max: fixedOptions.particles.opacity.value,
|
216
|
+
}
|
217
|
+
: fixedOptions.particles.opacity.value,
|
218
|
+
animation: {
|
219
|
+
enable: fixedOptions.particles.opacity.anim.enable,
|
220
|
+
speed: fixedOptions.particles.opacity.anim.speed,
|
221
|
+
sync: fixedOptions.particles.opacity.anim.sync,
|
222
|
+
},
|
223
|
+
},
|
224
|
+
size: {
|
225
|
+
value: fixedOptions.particles.size.random
|
226
|
+
? {
|
227
|
+
min: fixedOptions.particles.size.anim.enable
|
228
|
+
? fixedOptions.particles.size.anim.size_min
|
229
|
+
: 0,
|
230
|
+
max: fixedOptions.particles.size.value,
|
231
|
+
}
|
232
|
+
: fixedOptions.particles.size.value,
|
233
|
+
animation: {
|
234
|
+
enable: fixedOptions.particles.size.anim.enable,
|
235
|
+
speed: fixedOptions.particles.size.anim.speed,
|
236
|
+
sync: fixedOptions.particles.size.anim.sync,
|
237
|
+
},
|
238
|
+
},
|
239
|
+
links: {
|
240
|
+
enable: fixedOptions.particles.line_linked.enable,
|
241
|
+
distance: fixedOptions.particles.line_linked.distance,
|
242
|
+
color: fixedOptions.particles.line_linked.color,
|
243
|
+
opacity: fixedOptions.particles.line_linked.opacity,
|
244
|
+
width: fixedOptions.particles.line_linked.width,
|
245
|
+
},
|
246
|
+
move: {
|
247
|
+
enable: fixedOptions.particles.move.enable,
|
248
|
+
speed: fixedOptions.particles.move.speed / 3,
|
249
|
+
direction: fixedOptions.particles.move.direction,
|
250
|
+
random: fixedOptions.particles.move.random,
|
251
|
+
straight: fixedOptions.particles.move.straight,
|
252
|
+
outModes: fixedOptions.particles.move.out_mode,
|
253
|
+
attract: {
|
254
|
+
enable: fixedOptions.particles.move.attract.enable,
|
255
|
+
rotate: {
|
256
|
+
x: fixedOptions.particles.move.attract.rotateX,
|
257
|
+
y: fixedOptions.particles.move.attract.rotateY,
|
258
|
+
},
|
259
|
+
},
|
260
|
+
},
|
261
|
+
},
|
262
|
+
},
|
263
|
+
});
|
264
|
+
};
|
265
|
+
particlesJS.load = (tagId, pathConfigJson, callback) => {
|
266
|
+
engine
|
267
|
+
.load({ id: tagId, url: pathConfigJson })
|
268
|
+
.then((container) => {
|
269
|
+
if (container) {
|
270
|
+
callback(container);
|
271
|
+
}
|
272
|
+
})
|
273
|
+
.catch(() => {
|
274
|
+
callback(undefined);
|
275
|
+
});
|
276
|
+
};
|
277
|
+
particlesJS.setOnClickHandler = (callback) => {
|
278
|
+
engine.setOnClickHandler(callback);
|
279
|
+
};
|
280
|
+
const pJSDom = engine.dom();
|
281
|
+
return { particlesJS, pJSDom };
|
282
|
+
};
|
283
|
+
exports.initParticlesJS = initParticlesJS;
|
284
|
+
});
|
package/umd/bundle.js
CHANGED
@@ -23,11 +23,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
23
23
|
})(function (require, exports) {
|
24
24
|
"use strict";
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
exports.pJSDom = exports.particlesJS = void 0;
|
26
|
+
exports.Particles = exports.pJSDom = exports.particlesJS = void 0;
|
27
27
|
const _1 = require(".");
|
28
28
|
const engine_1 = require("@tsparticles/engine");
|
29
|
-
const { particlesJS, pJSDom } = (0, _1.initPjs)(engine_1.tsParticles);
|
29
|
+
const { particlesJS, pJSDom, Particles } = (0, _1.initPjs)(engine_1.tsParticles);
|
30
30
|
exports.particlesJS = particlesJS;
|
31
31
|
exports.pJSDom = pJSDom;
|
32
|
+
exports.Particles = Particles;
|
32
33
|
__exportStar(require("@tsparticles/engine"), exports);
|
33
34
|
});
|
package/umd/index.js
CHANGED
@@ -4,33 +4,20 @@
|
|
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", "./marcbruederlin/Particles.js", "./VincentGarreau/particles.js"], factory);
|
8
8
|
}
|
9
9
|
})(function (require, exports) {
|
10
10
|
"use strict";
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
12
|
exports.initPjs = void 0;
|
13
|
+
const Particles_js_1 = require("./marcbruederlin/Particles.js");
|
14
|
+
const particles_js_1 = require("./VincentGarreau/particles.js");
|
13
15
|
const initPjs = (engine) => {
|
14
|
-
const particlesJS = (
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
.load({ id: tagId, url: pathConfigJson })
|
20
|
-
.then((container) => {
|
21
|
-
if (container) {
|
22
|
-
callback(container);
|
23
|
-
}
|
24
|
-
})
|
25
|
-
.catch(() => {
|
26
|
-
callback(undefined);
|
27
|
-
});
|
28
|
-
};
|
29
|
-
particlesJS.setOnClickHandler = (callback) => {
|
30
|
-
engine.setOnClickHandler(callback);
|
31
|
-
};
|
32
|
-
const pJSDom = engine.dom();
|
33
|
-
return { particlesJS, pJSDom };
|
16
|
+
const { particlesJS, pJSDom } = (0, particles_js_1.initParticlesJS)(engine);
|
17
|
+
window.particlesJS = particlesJS;
|
18
|
+
window.pJSDom = pJSDom;
|
19
|
+
window.Particles = Particles_js_1.Particles;
|
20
|
+
return { particlesJS, pJSDom, Particles: Particles_js_1.Particles };
|
34
21
|
};
|
35
22
|
exports.initPjs = initPjs;
|
36
23
|
});
|
@@ -0,0 +1,97 @@
|
|
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"], factory);
|
8
|
+
}
|
9
|
+
})(function (require, exports) {
|
10
|
+
"use strict";
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.Particles = void 0;
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
14
|
+
class Particles {
|
15
|
+
static init(options) {
|
16
|
+
const particles = new Particles(), selector = options.selector;
|
17
|
+
if (!selector) {
|
18
|
+
throw new Error("No selector provided");
|
19
|
+
}
|
20
|
+
const el = document.querySelector(selector);
|
21
|
+
if (!el) {
|
22
|
+
throw new Error("No element found for selector");
|
23
|
+
}
|
24
|
+
engine_1.tsParticles
|
25
|
+
.load({
|
26
|
+
id: selector.replace(".", "").replace("!", ""),
|
27
|
+
element: el,
|
28
|
+
options: {
|
29
|
+
fullScreen: {
|
30
|
+
enable: false,
|
31
|
+
},
|
32
|
+
particles: {
|
33
|
+
color: {
|
34
|
+
value: options.color ?? "!000000",
|
35
|
+
},
|
36
|
+
links: {
|
37
|
+
color: "random",
|
38
|
+
distance: options.minDistance ?? 120,
|
39
|
+
enable: options.connectParticles ?? false,
|
40
|
+
},
|
41
|
+
move: {
|
42
|
+
enable: true,
|
43
|
+
speed: options.speed ?? 0.5,
|
44
|
+
},
|
45
|
+
number: {
|
46
|
+
value: options.maxParticles ?? 100,
|
47
|
+
},
|
48
|
+
size: {
|
49
|
+
value: { min: 1, max: options.sizeVariations ?? 3 },
|
50
|
+
},
|
51
|
+
},
|
52
|
+
responsive: options.responsive?.map((responsive) => ({
|
53
|
+
maxWidth: responsive.breakpoint,
|
54
|
+
options: {
|
55
|
+
particles: {
|
56
|
+
color: {
|
57
|
+
value: responsive.options?.color,
|
58
|
+
},
|
59
|
+
links: {
|
60
|
+
distance: responsive.options?.minDistance,
|
61
|
+
enable: responsive.options?.connectParticles,
|
62
|
+
},
|
63
|
+
number: {
|
64
|
+
value: options.maxParticles,
|
65
|
+
},
|
66
|
+
move: {
|
67
|
+
enable: true,
|
68
|
+
speed: responsive.options?.speed,
|
69
|
+
},
|
70
|
+
size: {
|
71
|
+
value: responsive.options?.sizeVariations,
|
72
|
+
},
|
73
|
+
},
|
74
|
+
},
|
75
|
+
})),
|
76
|
+
},
|
77
|
+
})
|
78
|
+
.then((container) => {
|
79
|
+
particles._container = container;
|
80
|
+
});
|
81
|
+
return particles;
|
82
|
+
}
|
83
|
+
destroy() {
|
84
|
+
const container = this._container;
|
85
|
+
container && container.destroy();
|
86
|
+
}
|
87
|
+
pauseAnimation() {
|
88
|
+
const container = this._container;
|
89
|
+
container && container.pause();
|
90
|
+
}
|
91
|
+
resumeAnimation() {
|
92
|
+
const container = this._container;
|
93
|
+
container && container.play();
|
94
|
+
}
|
95
|
+
}
|
96
|
+
exports.Particles = Particles;
|
97
|
+
});
|
package/types/IParticlesJS.d.ts
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
import type { Container, ISourceOptions } from "@tsparticles/engine";
|
2
|
-
export interface IParticlesJS {
|
3
|
-
(tagId: string, options: ISourceOptions): Promise<Container | undefined>;
|
4
|
-
load(tagId: string, pathConfigJson: string, callback: (container?: Container) => void): void;
|
5
|
-
setOnClickHandler(callback: EventListenerOrEventListenerObject): void;
|
6
|
-
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|