@tsparticles/preset-confetti 3.0.1 → 3.1.0

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.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/preset-confetti/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/preset-confetti) [![npmjs](https://badge.fury.io/js/@tsparticles/preset-confetti.svg)](https://www.npmjs.com/package/@tsparticles/preset-confetti) [![npmjs](https://img.shields.io/npm/dt/@tsparticles/preset-confetti)](https://www.npmjs.com/package/@tsparticles/preset-confetti) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
6
6
 
7
- [tsParticles](https://github.com/matteobruni/tsparticles) preset for white and red confetti launched from the screen
7
+ [tsParticles](https://github.com/tsparticles/tsparticles) preset for white and red confetti launched from the screen
8
8
  center on a transparent background.
9
9
 
10
10
  [![Slack](https://particles.js.org/images/slack.png)](https://join.slack.com/t/tsparticles/shared_invite/enQtOTcxNTQxNjQ4NzkxLWE2MTZhZWExMWRmOWI5MTMxNjczOGE1Yjk0MjViYjdkYTUzODM3OTc5MGQ5MjFlODc4MzE0N2Q1OWQxZDc1YzI) [![Discord](https://particles.js.org/images/discord.png)](https://discord.gg/hACwv45Hme) [![Telegram](https://particles.js.org/images/telegram.png)](https://t.me/tsparticles)
@@ -13,43 +13,14 @@ center on a transparent background.
13
13
 
14
14
  ## Sample
15
15
 
16
- [![demo](https://raw.githubusercontent.com/matteobruni/tsparticles/main/presets/confetti/images/sample.png)](https://particles.js.org/samples/presets/confetti)
16
+ [![demo](https://raw.githubusercontent.com/tsparticles/tsparticles/main/presets/confetti/images/sample.png)](https://particles.js.org/samples/presets/confetti)
17
17
 
18
18
  ## How to use it
19
19
 
20
20
  ### CDN / Vanilla JS / jQuery
21
21
 
22
- The first step is installing [tsParticles](https://github.com/matteobruni/tsparticles) following the instructions for
23
- vanilla javascript in the main project [here](https://github.com/matteobruni/tsparticles)
24
-
25
- Once added the script you need one more script to be included in your page (or you can download that
26
- from [jsDelivr](https://www.jsdelivr.com/package/npm/@tsparticles/preset-confetti):
27
-
28
22
  ```html
29
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/engine@2/tsparticles.engine.min.js"></script>
30
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/basic@2/tsparticles.basic.min.js"></script>
31
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/move-base@2/tsparticles.move.base.min.js"></script>
32
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/plugin-emitters@2/tsparticles.plugin.emitters.min.js"></script>
33
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/shape-circle@2/tsparticles.shape.circle.min.js"></script>
34
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/shape-square@2/tsparticles.shape.square.min.js"></script>
35
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/updater-color@2/tsparticles.updater.color.min.js"></script>
36
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/updater-life@2/tsparticles.updater.life.min.js"></script>
37
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/updater-opacity@2/tsparticles.updater.opacity.min.js"></script>
38
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/updater-out-modes@2/tsparticles.updater.out-modes.min.js"></script>
39
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/updater-roll@2/tsparticles.updater.roll.min.js"></script>
40
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/updater-rotate@2/tsparticles.updater.angle.min.js"></script>
41
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/updater-size@2/tsparticles.updater.size.min.js"></script>
42
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/updater-tilt@2/tsparticles.updater.tilt.min.js"></script>
43
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/updater-wobble@2/tsparticles.updater.wobble.min.js"></script>
44
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/preset-confetti@2/tsparticles.preset.confetti.min.js"></script>
45
- ```
46
-
47
- #### Bundle
48
-
49
- A bundled script can also be used, this will include every needed plugin needed by the preset.
50
-
51
- ```html
52
- <script src="https://cdn.jsdelivr.net/npm/@tsparticles/preset-confetti@2/tsparticles.preset.confetti.bundle.min.js"></script>
23
+ <script src="https://cdn.jsdelivr.net/npm/@tsparticles/preset-confetti@3/tsparticles.preset.confetti.bundle.min.js"></script>
53
24
  ```
54
25
 
55
26
  ### Usage
@@ -57,25 +28,27 @@ A bundled script can also be used, this will include every needed plugin needed
57
28
  Once the scripts are loaded you can set up `tsParticles` like this:
58
29
 
59
30
  ```javascript
60
- (async () => {
61
- await loadConfettiPreset(tsParticles); // this is required only if you are not using the bundle script
62
-
63
- await tsParticles.load("tsparticles", {
31
+ tsParticles.load({
32
+ id: "tsparticles",
33
+ options: {
64
34
  preset: "confetti",
65
- });
66
- })();
35
+ },
36
+ });
67
37
  ```
68
38
 
69
39
  ### Customization
70
40
 
71
41
  ```javascript
72
- tsParticles.load("tsparticles", {
73
- particles: {
74
- color: {
75
- value: ["#0000ff", "#00ff00"],
42
+ tsParticles.load({
43
+ id: "tsparticles",
44
+ options: {
45
+ particles: {
46
+ color: {
47
+ value: ["#0000ff", "#00ff00"],
48
+ },
76
49
  },
50
+ preset: "confetti",
77
51
  },
78
- preset: "confetti",
79
52
  });
80
53
  ```
81
54
 
@@ -132,13 +105,16 @@ will last forever.
132
105
  ###### Sample
133
106
 
134
107
  ```javascript
135
- tsParticles.load("tsparticles", {
136
- emitters: {
137
- life: {
138
- duration: 0,
108
+ tsParticles.load({
109
+ id: "tsparticles",
110
+ options: {
111
+ emitters: {
112
+ life: {
113
+ duration: 0,
114
+ },
139
115
  },
116
+ preset: "confetti",
140
117
  },
141
- preset: "confetti",
142
118
  });
143
119
  ```
144
120
 
@@ -159,22 +135,25 @@ have a random position every "explosion". If a coordinate is set, that will be u
159
135
  canvas size.
160
136
 
161
137
  ```javascript
162
- tsParticles.load("tsparticles", {
163
- emitters: {
164
- life: {
165
- count: 0,
166
- },
167
- position: {
168
- // uncomment only one of these lines,
169
- // to have explosions on the x or y axis
170
- // centered on the other one
171
- // if everything is kept commented,
172
- // random positions will be used everytime the cannon fires
173
- // x: 50,
174
- // y: 50
138
+ tsParticles.load({
139
+ id: "tsparticles",
140
+ options: {
141
+ emitters: {
142
+ life: {
143
+ count: 0,
144
+ },
145
+ position: {
146
+ // uncomment only one of these lines,
147
+ // to have explosions on the x or y axis
148
+ // centered on the other one
149
+ // if everything is kept commented,
150
+ // random positions will be used everytime the cannon fires
151
+ // x: 50,
152
+ // y: 50
153
+ },
175
154
  },
155
+ preset: "confetti",
176
156
  },
177
- preset: "confetti",
178
157
  });
179
158
  ```
180
159
 
@@ -189,9 +168,12 @@ First let's start overriding the emitters (cannons) options placing an array ins
189
168
  Like this:
190
169
 
191
170
  ```javascript
192
- tsParticles.load("tsparticles", {
193
- emitters: [],
194
- preset: "confetti",
171
+ tsParticles.load({
172
+ id: "tsparticles",
173
+ options: {
174
+ emitters: [],
175
+ preset: "confetti",
176
+ },
195
177
  });
196
178
  ```
197
179
 
@@ -202,128 +184,54 @@ Now you can add emitters to the array, using the standard tsParticles emitters o
202
184
  ###### Sample
203
185
 
204
186
  ```javascript
205
- tsParticles.load("tsparticles", {
206
- emitters: [
207
- {
208
- life: {
209
- duration: 5,
210
- count: 1,
211
- },
212
- position: {
213
- x: 0,
214
- y: 30,
215
- },
216
- particles: {
217
- move: {
218
- direction: "top-right",
187
+ tsParticles.load({
188
+ id: "tsparticles",
189
+ options: {
190
+ emitters: [
191
+ {
192
+ life: {
193
+ duration: 5,
194
+ count: 1,
195
+ },
196
+ position: {
197
+ x: 0,
198
+ y: 30,
199
+ },
200
+ particles: {
201
+ move: {
202
+ direction: "top-right",
203
+ },
219
204
  },
220
205
  },
221
- },
222
- {
223
- life: {
224
- duration: 5,
225
- count: 1,
226
- },
227
- position: {
228
- x: 100,
229
- y: 30,
230
- },
231
- particles: {
232
- move: {
233
- direction: "top-left",
206
+ {
207
+ life: {
208
+ duration: 5,
209
+ count: 1,
210
+ },
211
+ position: {
212
+ x: 100,
213
+ y: 30,
214
+ },
215
+ particles: {
216
+ move: {
217
+ direction: "top-left",
218
+ },
234
219
  },
235
220
  },
236
- },
237
- ],
238
- preset: "confetti",
221
+ ],
222
+ preset: "confetti",
223
+ },
239
224
  });
240
225
  ```
241
226
 
242
227
  This samples creates two cannons, one on the left and one on the right of the canvas, at 30% of canvas height, shooting
243
228
  in opposite directions.
244
229
 
245
- ### React.js / Preact / Inferno
246
-
247
- _The syntax for `React.js`, `Preact` and `Inferno` is the same_.
248
-
249
- This sample uses the class component syntax, but you can use hooks as well (if the library supports it).
250
-
251
- ```typescript jsx
252
- import Particles from "react-particles";
253
- import type { Engine } from "@tsparticles/engine";
254
- import { loadConfettiPreset } from "@tsparticles/preset-confetti";
255
-
256
- export class ParticlesContainer extends React.PureComponent<IProps> {
257
- // this customizes the component tsParticles installation
258
- async customInit(engine: Engine): Promise<void> {
259
- // this adds the preset to tsParticles, you can safely use the
260
- await loadConfettiPreset(engine);
261
- }
262
-
263
- render() {
264
- const options = {
265
- preset: "confetti",
266
- };
267
-
268
- return <Particles options={options} init={this.customInit} />;
269
- }
270
- }
271
- ```
272
-
273
- ### Vue (2.x and 3.x)
274
-
275
- _The syntax for `Vue.js 2.x` and `3.x` is the same_
276
-
277
- ```vue
278
- <Particles id="tsparticles" :particlesInit="particlesInit" :options="particlesOptions" />
279
- ```
230
+ ### Frameworks with a tsParticles component library
280
231
 
281
- ```ts
282
- const particlesOptions = {
283
- preset: "confetti",
284
- };
232
+ Checkout the documentation in the component library repository and call the `loadConfettiPreset` function instead of `loadFull`, `loadSlim` or similar functions.
285
233
 
286
- async function particlesInit(engine: Engine): Promise<void> {
287
- await loadConfettiPreset(engine);
288
- }
289
- ```
290
-
291
- ### Angular
292
-
293
- ```html
294
- <ng-particles [id]="id" [options]="particlesOptions" [particlesInit]="particlesInit"></ng-particles>
295
- ```
296
-
297
- ```ts
298
- const particlesOptions = {
299
- preset: "confetti",
300
- };
301
-
302
- async function particlesInit(engine: Engine): Promise<void> {
303
- await loadConfettiPreset(engine);
304
- }
305
- ```
306
-
307
- ### Svelte
308
-
309
- ```sveltehtml
310
-
311
- <Particles
312
- id="tsparticles"
313
- options={options}
314
- particlesInit={particlesInit}
315
- />
316
- ```
317
-
318
- ```js
319
- let particlesOptions = {
320
- preset: "confetti",
321
- };
322
-
323
- let particlesInit = async (engine) => {
324
- await loadConfettiPreset(engine);
325
- };
326
- ```
234
+ The options shown above are valid for all the component libraries.
327
235
 
328
236
  ---
329
237
 
package/browser/bundle.js CHANGED
@@ -1,4 +1,3 @@
1
1
  import { loadConfettiPreset } from "./index.js";
2
2
  import { tsParticles } from "@tsparticles/engine";
3
- void loadConfettiPreset(tsParticles);
4
3
  export { loadConfettiPreset, tsParticles };
package/browser/index.js CHANGED
@@ -18,7 +18,8 @@ async function loadPreset(engine, refresh = true) {
18
18
  await loadRotateUpdater(engine, false);
19
19
  await loadTiltUpdater(engine, false);
20
20
  await loadLifeUpdater(engine, false);
21
- await engine.addPreset("confetti", options, refresh);
21
+ await engine.addPreset("confetti", options, false);
22
+ await engine.refresh(refresh);
22
23
  }
23
24
  export async function loadConfettiPreset(engine) {
24
25
  await loadPreset(engine);
package/cjs/bundle.js CHANGED
@@ -5,4 +5,3 @@ const index_js_1 = require("./index.js");
5
5
  Object.defineProperty(exports, "loadConfettiPreset", { enumerable: true, get: function () { return index_js_1.loadConfettiPreset; } });
6
6
  const engine_1 = require("@tsparticles/engine");
7
7
  Object.defineProperty(exports, "tsParticles", { enumerable: true, get: function () { return engine_1.tsParticles; } });
8
- void (0, index_js_1.loadConfettiPreset)(engine_1.tsParticles);
package/cjs/index.js CHANGED
@@ -21,7 +21,8 @@ async function loadPreset(engine, refresh = true) {
21
21
  await (0, updater_rotate_1.loadRotateUpdater)(engine, false);
22
22
  await (0, updater_tilt_1.loadTiltUpdater)(engine, false);
23
23
  await (0, updater_life_1.loadLifeUpdater)(engine, false);
24
- await engine.addPreset("confetti", options_js_1.options, refresh);
24
+ await engine.addPreset("confetti", options_js_1.options, false);
25
+ await engine.refresh(refresh);
25
26
  }
26
27
  async function loadConfettiPreset(engine) {
27
28
  await loadPreset(engine);
package/esm/bundle.js CHANGED
@@ -1,4 +1,3 @@
1
1
  import { loadConfettiPreset } from "./index.js";
2
2
  import { tsParticles } from "@tsparticles/engine";
3
- void loadConfettiPreset(tsParticles);
4
3
  export { loadConfettiPreset, tsParticles };
package/esm/index.js CHANGED
@@ -18,7 +18,8 @@ async function loadPreset(engine, refresh = true) {
18
18
  await loadRotateUpdater(engine, false);
19
19
  await loadTiltUpdater(engine, false);
20
20
  await loadLifeUpdater(engine, false);
21
- await engine.addPreset("confetti", options, refresh);
21
+ await engine.addPreset("confetti", options, false);
22
+ await engine.refresh(refresh);
22
23
  }
23
24
  export async function loadConfettiPreset(engine) {
24
25
  await loadPreset(engine);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/preset-confetti",
3
- "version": "3.0.1",
3
+ "version": "3.1.0",
4
4
  "description": "tsParticles confetti preset",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -87,16 +87,16 @@
87
87
  "module": "esm/index.js",
88
88
  "types": "types/index.d.ts",
89
89
  "dependencies": {
90
- "@tsparticles/basic": "^3.0.0",
91
- "@tsparticles/engine": "^3.0.0",
92
- "@tsparticles/plugin-emitters": "^3.0.0",
93
- "@tsparticles/plugin-motion": "^3.0.0",
94
- "@tsparticles/shape-square": "^3.0.0",
95
- "@tsparticles/updater-life": "^3.0.0",
96
- "@tsparticles/updater-roll": "^3.0.0",
97
- "@tsparticles/updater-rotate": "^3.0.0",
98
- "@tsparticles/updater-tilt": "^3.0.0",
99
- "@tsparticles/updater-wobble": "^3.0.0"
90
+ "@tsparticles/basic": "^3.4.0",
91
+ "@tsparticles/engine": "^3.4.0",
92
+ "@tsparticles/plugin-emitters": "^3.4.0",
93
+ "@tsparticles/plugin-motion": "^3.4.0",
94
+ "@tsparticles/shape-square": "^3.4.0",
95
+ "@tsparticles/updater-life": "^3.4.0",
96
+ "@tsparticles/updater-roll": "^3.4.0",
97
+ "@tsparticles/updater-rotate": "^3.4.0",
98
+ "@tsparticles/updater-tilt": "^3.4.0",
99
+ "@tsparticles/updater-wobble": "^3.4.0"
100
100
  },
101
101
  "publishConfig": {
102
102
  "access": "public"