@tsparticles/confetti 4.0.0-beta.8 → 4.0.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 +106 -107
- package/browser/ConfettiParams.js +1 -0
- package/browser/browser.js +5 -0
- package/browser/bundle.js +4 -0
- package/browser/confetti.js +37 -302
- package/browser/confetti.lazy.js +96 -0
- package/browser/index.lazy.js +1 -0
- package/browser/types.js +1 -0
- package/browser/utils.js +279 -0
- package/cjs/ConfettiParams.js +1 -0
- package/cjs/browser.js +5 -0
- package/cjs/bundle.js +4 -0
- package/cjs/confetti.js +37 -302
- package/cjs/confetti.lazy.js +96 -0
- package/cjs/index.lazy.js +1 -0
- package/cjs/types.js +1 -0
- package/cjs/utils.js +279 -0
- package/esm/ConfettiParams.js +1 -0
- package/esm/browser.js +5 -0
- package/esm/bundle.js +4 -0
- package/esm/confetti.js +37 -302
- package/esm/confetti.lazy.js +96 -0
- package/esm/index.lazy.js +1 -0
- package/esm/types.js +1 -0
- package/esm/utils.js +279 -0
- package/package.json +24 -17
- package/report.html +4949 -94
- package/tsparticles.confetti.bundle.js +9847 -977
- package/tsparticles.confetti.bundle.min.js +1 -2
- package/tsparticles.confetti.js +512 -322
- package/tsparticles.confetti.min.js +1 -1
- package/types/ConfettiParams.d.ts +7 -0
- package/types/browser.d.ts +1 -0
- package/types/confetti.d.ts +3 -10
- package/types/confetti.lazy.d.ts +16 -0
- package/types/index.d.ts +1 -0
- package/types/index.lazy.d.ts +5 -0
- package/types/types.d.ts +4 -0
- package/types/utils.d.ts +7 -0
- package/1080.min.js +0 -1
- package/1241.min.js +0 -1
- package/1336.min.js +0 -1
- package/1581.min.js +0 -1
- package/1583.min.js +0 -1
- package/1712.min.js +0 -1
- package/1723.min.js +0 -1
- package/189.min.js +0 -1
- package/2066.min.js +0 -1
- package/2127.min.js +0 -1
- package/2182.min.js +0 -1
- package/2270.min.js +0 -1
- package/2528.min.js +0 -1
- package/2602.min.js +0 -1
- package/2760.min.js +0 -1
- package/3047.min.js +0 -1
- package/3073.min.js +0 -1
- package/3443.min.js +0 -1
- package/3583.min.js +0 -1
- package/374.min.js +0 -1
- package/382.min.js +0 -1
- package/404.min.js +0 -1
- package/4067.min.js +0 -1
- package/4068.min.js +0 -1
- package/4077.min.js +0 -1
- package/4086.min.js +0 -1
- package/4186.min.js +0 -1
- package/4217.min.js +0 -1
- package/4427.min.js +0 -1
- package/4519.min.js +0 -1
- package/4626.min.js +0 -1
- package/4657.min.js +0 -1
- package/5048.min.js +0 -1
- package/5294.min.js +0 -1
- package/5344.min.js +0 -1
- package/5601.min.js +0 -1
- package/6055.min.js +0 -1
- package/6171.min.js +0 -1
- package/6192.min.js +0 -1
- package/6265.min.js +0 -1
- package/6466.min.js +0 -1
- package/648.min.js +0 -1
- package/6943.min.js +0 -1
- package/6957.min.js +0 -1
- package/6972.min.js +0 -1
- package/6996.min.js +0 -1
- package/7162.min.js +0 -1
- package/7175.min.js +0 -1
- package/7213.min.js +0 -1
- package/7259.min.js +0 -1
- package/7316.min.js +0 -1
- package/7711.min.js +0 -1
- package/7757.min.js +0 -1
- package/7775.min.js +0 -1
- package/8204.min.js +0 -1
- package/8630.min.js +0 -1
- package/8731.min.js +0 -1
- package/8855.min.js +0 -1
- package/9674.min.js +0 -1
- package/9726.min.js +0 -1
- package/980.min.js +0 -1
- package/9835.min.js +0 -1
- package/9907.min.js +0 -1
- package/basic_dist_browser_index_js.js +0 -30
- package/engine_dist_browser_Core_Container_js.js +0 -100
- package/plugins_colors_hex_dist_browser_HexColorManager_js.js +0 -30
- package/plugins_colors_hex_dist_browser_index_js.js +0 -30
- package/plugins_colors_hsl_dist_browser_HslColorManager_js.js +0 -30
- package/plugins_colors_hsl_dist_browser_index_js.js +0 -30
- package/plugins_colors_rgb_dist_browser_RgbColorManager_js.js +0 -30
- package/plugins_colors_rgb_dist_browser_index_js.js +0 -30
- package/plugins_emitters_dist_browser_EmitterInstance_js.js +0 -30
- package/plugins_emitters_dist_browser_EmittersInstancesManager_js.js +0 -100
- package/plugins_emitters_dist_browser_EmittersPluginInstance_js.js +0 -30
- package/plugins_emitters_dist_browser_EmittersPlugin_js.js +0 -100
- package/plugins_emitters_dist_browser_ShapeManager_js.js +0 -30
- package/plugins_emitters_dist_browser_addEmittersShapesManager_js.js +0 -30
- package/plugins_emitters_dist_browser_getEmittersInstancesManager_js.js +0 -30
- package/plugins_emitters_dist_browser_plugin_js.js +0 -50
- package/plugins_motion_dist_browser_MotionPluginInstance_js.js +0 -30
- package/plugins_motion_dist_browser_MotionPlugin_js.js +0 -50
- package/plugins_motion_dist_browser_index_js.js +0 -30
- package/plugins_move_dist_browser_MovePluginInstance_js.js +0 -40
- package/plugins_move_dist_browser_MovePlugin_js.js +0 -30
- package/plugins_move_dist_browser_index_js.js +0 -30
- package/shapes_cards_dist_browser_clubs_ClubDrawer_js.js +0 -30
- package/shapes_cards_dist_browser_diamonds_DiamondDrawer_js.js +0 -30
- package/shapes_cards_dist_browser_hearts_HeartDrawer_js.js +0 -30
- package/shapes_cards_dist_browser_paths_js.js +0 -70
- package/shapes_cards_dist_browser_spades_SpadeDrawer_js.js +0 -30
- package/shapes_cards_dist_browser_suits_js.js +0 -70
- package/shapes_circle_dist_browser_CircleDrawer_js.js +0 -40
- package/shapes_circle_dist_browser_index_js.js +0 -30
- package/shapes_emoji_dist_browser_EmojiDrawer_js.js +0 -50
- package/shapes_emoji_dist_browser_index_js.js +0 -40
- package/shapes_heart_dist_browser_HeartDrawer_js.js +0 -40
- package/shapes_heart_dist_browser_index_js.js +0 -30
- package/shapes_image_dist_browser_GifUtils_Utils_js.js +0 -70
- package/shapes_image_dist_browser_ImageDrawer_js.js +0 -30
- package/shapes_image_dist_browser_ImagePreloaderInstance_js.js +0 -30
- package/shapes_image_dist_browser_ImagePreloader_js.js +0 -40
- package/shapes_image_dist_browser_index_js.js +0 -40
- package/shapes_polygon_dist_browser_PolygonDrawer_js.js +0 -50
- package/shapes_polygon_dist_browser_TriangleDrawer_js.js +0 -50
- package/shapes_polygon_dist_browser_index_js.js +0 -30
- package/shapes_square_dist_browser_SquareDrawer_js.js +0 -40
- package/shapes_square_dist_browser_index_js.js +0 -30
- package/shapes_star_dist_browser_StarDrawer_js.js +0 -40
- package/shapes_star_dist_browser_index_js.js +0 -30
- package/updaters_fillColor_dist_browser_FillColorUpdater_js.js +0 -30
- package/updaters_fillColor_dist_browser_index_js.js +0 -30
- package/updaters_life_dist_browser_LifeUpdater_js.js +0 -70
- package/updaters_life_dist_browser_index_js.js +0 -30
- package/updaters_opacity_dist_browser_OpacityUpdater_js.js +0 -30
- package/updaters_opacity_dist_browser_index_js.js +0 -30
- package/updaters_outModes_dist_browser_OutOfCanvasUpdater_js.js +0 -80
- package/updaters_outModes_dist_browser_index_js.js +0 -30
- package/updaters_roll_dist_browser_RollUpdater_js.js +0 -70
- package/updaters_roll_dist_browser_index_js.js +0 -30
- package/updaters_rotate_dist_browser_RotateUpdater_js.js +0 -50
- package/updaters_rotate_dist_browser_index_js.js +0 -30
- package/updaters_size_dist_browser_SizeUpdater_js.js +0 -30
- package/updaters_size_dist_browser_index_js.js +0 -30
- package/updaters_tilt_dist_browser_TiltUpdater_js.js +0 -60
- package/updaters_tilt_dist_browser_index_js.js +0 -30
- package/updaters_wobble_dist_browser_WobbleUpdater_js.js +0 -60
- package/updaters_wobble_dist_browser_index_js.js +0 -30
package/README.md
CHANGED
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://www.jsdelivr.com/package/npm/@tsparticles/confetti) [](https://www.npmjs.com/package/@tsparticles/confetti) [](https://www.npmjs.com/package/@tsparticles/confetti) [](https://github.com/sponsors/matteobruni)
|
|
6
6
|
|
|
7
|
-
[tsParticles](https://github.com/tsparticles/tsparticles) confetti bundle
|
|
8
|
-
beautiful confetti effects with ease.
|
|
7
|
+
[tsParticles](https://github.com/tsparticles/tsparticles) confetti bundle to create confetti effects with a single API.
|
|
9
8
|
|
|
10
9
|
**Included Packages**
|
|
11
10
|
|
|
@@ -70,30 +69,84 @@ bc --> s
|
|
|
70
69
|
bc --> u
|
|
71
70
|
```
|
|
72
71
|
|
|
73
|
-
##
|
|
72
|
+
## Exposed API
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
The package API is centered on `confetti`.
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import { confetti } from "@tsparticles/confetti";
|
|
78
|
+
|
|
79
|
+
// Main API
|
|
80
|
+
await confetti(options);
|
|
81
|
+
await confetti("canvas-id", options);
|
|
82
|
+
|
|
83
|
+
// Extra helpers
|
|
84
|
+
await confetti.init();
|
|
85
|
+
const fireOnCanvas = await confetti.create(canvas, defaultOptions);
|
|
86
|
+
await fireOnCanvas(options);
|
|
87
|
+
|
|
88
|
+
console.log(confetti.version);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`@tsparticles/confetti` does not expose `tsParticles` from its main entrypoint.
|
|
92
|
+
If you need direct engine APIs, import them from `@tsparticles/engine`.
|
|
93
|
+
|
|
94
|
+
## Installation
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
pnpm add @tsparticles/confetti
|
|
98
|
+
```
|
|
78
99
|
|
|
79
100
|
## How to use it
|
|
80
101
|
|
|
102
|
+
### ESM / TypeScript
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import { confetti } from "@tsparticles/confetti";
|
|
106
|
+
|
|
107
|
+
await confetti({
|
|
108
|
+
count: 80,
|
|
109
|
+
spread: 60,
|
|
110
|
+
position: { x: 50, y: 50 },
|
|
111
|
+
colors: ["#ffffff", "#ff0000"],
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
With explicit canvas id:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import { confetti } from "@tsparticles/confetti";
|
|
119
|
+
|
|
120
|
+
await confetti("tsparticles", {
|
|
121
|
+
count: 50,
|
|
122
|
+
angle: 90,
|
|
123
|
+
spread: 45,
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Custom canvas via `confetti.create`
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
import { confetti } from "@tsparticles/confetti";
|
|
131
|
+
|
|
132
|
+
const canvas = document.getElementById("my-canvas") as HTMLCanvasElement;
|
|
133
|
+
const localConfetti = await confetti.create(canvas, { count: 30 });
|
|
134
|
+
|
|
135
|
+
await localConfetti({ spread: 70 });
|
|
136
|
+
```
|
|
137
|
+
|
|
81
138
|
### CDN / Vanilla JS / jQuery
|
|
82
139
|
|
|
83
|
-
The CDN/Vanilla version
|
|
140
|
+
The CDN/Vanilla JS version has two files:
|
|
84
141
|
|
|
85
142
|
- One is a bundle file with all the scripts included in a single file
|
|
86
|
-
- One
|
|
87
|
-
be
|
|
88
|
-
included manually
|
|
143
|
+
- One includes only the `confetti` API, where dependencies must be loaded manually
|
|
89
144
|
|
|
90
|
-
|
|
145
|
+
After loading the bundle, `confetti` is available on `globalThis`.
|
|
91
146
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
This is the easiest usage, since it's a single file with all the features loaded.
|
|
147
|
+
#### Bundle
|
|
95
148
|
|
|
96
|
-
|
|
149
|
+
Use the bundle when you want a single script with all required dependencies.
|
|
97
150
|
|
|
98
151
|
#### Not Bundle
|
|
99
152
|
|
|
@@ -102,116 +155,62 @@ specified in the **Included Packages** section.
|
|
|
102
155
|
|
|
103
156
|
### Usage
|
|
104
157
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
** Easiest Way **
|
|
108
|
-
|
|
109
|
-
```javascript
|
|
110
|
-
confetti();
|
|
158
|
+
```js
|
|
159
|
+
confetti({ count: 60 });
|
|
111
160
|
```
|
|
112
161
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
```javascript
|
|
162
|
+
```js
|
|
116
163
|
(async () => {
|
|
117
|
-
await confetti();
|
|
164
|
+
await confetti({ count: 60, spread: 55 });
|
|
118
165
|
})();
|
|
119
166
|
```
|
|
120
167
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
```javascript
|
|
168
|
+
```js
|
|
124
169
|
confetti("tsparticles", {
|
|
125
|
-
/**
|
|
126
|
-
* @deprecated use count property instead
|
|
127
|
-
*/
|
|
128
|
-
particleCount: 50,
|
|
129
|
-
/**
|
|
130
|
-
* @deprecated use position property instead
|
|
131
|
-
*/
|
|
132
|
-
origin: {
|
|
133
|
-
x: 0.5,
|
|
134
|
-
y: 0.5,
|
|
135
|
-
},
|
|
136
|
-
//------------------------------------------
|
|
137
|
-
angle: 90,
|
|
138
170
|
count: 50,
|
|
139
171
|
position: {
|
|
140
172
|
x: 50,
|
|
141
173
|
y: 50,
|
|
142
174
|
},
|
|
143
|
-
spread: 45,
|
|
144
|
-
startVelocity: 45,
|
|
145
|
-
decay: 0.9,
|
|
146
|
-
gravity: 1,
|
|
147
|
-
drift: 0,
|
|
148
|
-
ticks: 200,
|
|
149
|
-
colors: ["#ffffff", "#ff0000"],
|
|
150
|
-
shapes: ["square", "circle"],
|
|
151
|
-
scalar: 1,
|
|
152
|
-
zIndex: 100,
|
|
153
|
-
disableForReducedMotion: true,
|
|
154
175
|
});
|
|
155
176
|
```
|
|
156
177
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
The `confetti`
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
- `
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
- `
|
|
168
|
-
- `
|
|
169
|
-
|
|
170
|
-
- `
|
|
171
|
-
|
|
172
|
-
- `gravity` _Number (default: 1)_
|
|
173
|
-
|
|
174
|
-
- `
|
|
175
|
-
|
|
176
|
-
- `
|
|
177
|
-
|
|
178
|
-
- `
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
- `
|
|
186
|
-
- `
|
|
187
|
-
- `circle`
|
|
188
|
-
- `square`
|
|
189
|
-
- `star`
|
|
190
|
-
- `polygon`
|
|
191
|
-
- `image`
|
|
192
|
-
- `heart`
|
|
193
|
-
- `hearts`
|
|
194
|
-
- `spades`
|
|
195
|
-
- `clubs`
|
|
196
|
-
- `diamonds`
|
|
197
|
-
- `text`
|
|
198
|
-
The default is to use both shapes in an even mix. You can even change the mix by providing a value such
|
|
199
|
-
as `['circle', 'circle', 'square']` to use two third circles and one third squares.
|
|
200
|
-
- `scalar` _Number (default: 1)_: Scale factor for each confetti particle. Use decimals to make the confetti smaller. Go
|
|
201
|
-
on, try teeny tiny confetti, they are adorable!
|
|
202
|
-
- `zIndex` _Integer (default: 100)_: The confetti should be on top, after all. But if you have a crazy high page, you
|
|
203
|
-
can set it even higher.
|
|
204
|
-
- `disableForReducedMotion` _Boolean (default: true)_: Disables confetti entirely for users
|
|
205
|
-
that [prefer reduced motion](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion).
|
|
206
|
-
|
|
207
|
-
And for those asking, yes you can paste your canvas-confetti code and migrate to tsParticles Confetti without changing a
|
|
208
|
-
thing
|
|
178
|
+
### Options
|
|
179
|
+
|
|
180
|
+
The `confetti` API accepts:
|
|
181
|
+
|
|
182
|
+
- `confetti(options)`
|
|
183
|
+
- `confetti(id, options)`
|
|
184
|
+
|
|
185
|
+
Main options:
|
|
186
|
+
|
|
187
|
+
- `count` _Integer (default: 50)_
|
|
188
|
+
- `angle` _Number (default: 90)_
|
|
189
|
+
- `spread` _Number (default: 45)_
|
|
190
|
+
- `startVelocity` _Number (default: 45)_
|
|
191
|
+
- `decay` _Number (default: 0.9)_
|
|
192
|
+
- `flat` _Boolean (default: false)_
|
|
193
|
+
- `gravity` _Number (default: 1)_
|
|
194
|
+
- `drift` _Number (default: 0)_
|
|
195
|
+
- `ticks` _Number (default: 200)_
|
|
196
|
+
- `position` _Object_ (`x`/`y`, default 50/50)
|
|
197
|
+
- `colors` _Array<String>_
|
|
198
|
+
- `shapes` _Array<String>_
|
|
199
|
+
- `shapeOptions` _Record<string, unknown>_
|
|
200
|
+
- `scalar` _Number (default: 1)_
|
|
201
|
+
- `zIndex` _Integer (default: 100)_
|
|
202
|
+
- `disableForReducedMotion` _Boolean (default: true)_
|
|
203
|
+
|
|
204
|
+
Deprecated aliases still accepted:
|
|
205
|
+
|
|
206
|
+
- `particleCount` (use `count`)
|
|
207
|
+
- `origin` (use `position`)
|
|
209
208
|
|
|
210
209
|
## Common pitfalls
|
|
211
210
|
|
|
212
|
-
- Calling `
|
|
213
|
-
-
|
|
214
|
-
-
|
|
211
|
+
- Calling `confetti` before scripts are loaded in CDN usage
|
|
212
|
+
- Assuming `tsParticles` is exported by `@tsparticles/confetti` main entrypoint
|
|
213
|
+
- Passing no first argument in TypeScript (use `confetti(options)` or `confetti(id, options)`)
|
|
215
214
|
|
|
216
215
|
## Related docs
|
|
217
216
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/browser/bundle.js
CHANGED
package/browser/confetti.js
CHANGED
|
@@ -1,42 +1,24 @@
|
|
|
1
|
-
import { isString,
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
engine.checkVersion("4.0.0-beta.8");
|
|
1
|
+
import { isString, tsParticles } from "@tsparticles/engine";
|
|
2
|
+
import { loadBasic } from "@tsparticles/basic";
|
|
3
|
+
import { loadCardSuitsShape } from "@tsparticles/shape-cards/suits";
|
|
4
|
+
import { loadEmittersPluginSimple } from "@tsparticles/plugin-emitters/plugin";
|
|
5
|
+
import { loadEmojiShape } from "@tsparticles/shape-emoji";
|
|
6
|
+
import { loadHeartShape } from "@tsparticles/shape-heart";
|
|
7
|
+
import { loadImageShape } from "@tsparticles/shape-image";
|
|
8
|
+
import { loadLifeUpdater } from "@tsparticles/updater-life";
|
|
9
|
+
import { loadMotionPlugin } from "@tsparticles/plugin-motion";
|
|
10
|
+
import { loadPolygonShape } from "@tsparticles/shape-polygon";
|
|
11
|
+
import { loadRollUpdater } from "@tsparticles/updater-roll";
|
|
12
|
+
import { loadRotateUpdater } from "@tsparticles/updater-rotate";
|
|
13
|
+
import { loadSquareShape } from "@tsparticles/shape-square";
|
|
14
|
+
import { loadStarShape } from "@tsparticles/shape-star";
|
|
15
|
+
import { loadTiltUpdater } from "@tsparticles/updater-tilt";
|
|
16
|
+
import { loadWobbleUpdater } from "@tsparticles/updater-wobble";
|
|
17
|
+
import { setConfetti } from "./utils.js";
|
|
18
|
+
let initPromise = null;
|
|
19
|
+
async function doInitPlugins(engine) {
|
|
20
|
+
engine.checkVersion("4.0.0");
|
|
22
21
|
await engine.pluginManager.register(async (e) => {
|
|
23
|
-
const [{ loadBasic }, { loadEmittersPluginSimple }, { loadMotionPlugin }, { loadCardSuitsShape }, { loadHeartShape }, { loadImageShape }, { loadPolygonShape }, { loadSquareShape }, { loadStarShape }, { loadEmojiShape }, { loadRotateUpdater }, { loadLifeUpdater }, { loadRollUpdater }, { loadTiltUpdater }, { loadWobbleUpdater },] = await Promise.all([
|
|
24
|
-
import("@tsparticles/basic"),
|
|
25
|
-
import("@tsparticles/plugin-emitters/plugin"),
|
|
26
|
-
import("@tsparticles/plugin-motion"),
|
|
27
|
-
import("@tsparticles/shape-cards/suits"),
|
|
28
|
-
import("@tsparticles/shape-heart"),
|
|
29
|
-
import("@tsparticles/shape-image"),
|
|
30
|
-
import("@tsparticles/shape-polygon"),
|
|
31
|
-
import("@tsparticles/shape-square"),
|
|
32
|
-
import("@tsparticles/shape-star"),
|
|
33
|
-
import("@tsparticles/shape-emoji"),
|
|
34
|
-
import("@tsparticles/updater-rotate"),
|
|
35
|
-
import("@tsparticles/updater-life"),
|
|
36
|
-
import("@tsparticles/updater-roll"),
|
|
37
|
-
import("@tsparticles/updater-tilt"),
|
|
38
|
-
import("@tsparticles/updater-wobble"),
|
|
39
|
-
]);
|
|
40
22
|
await Promise.all([
|
|
41
23
|
loadBasic(e),
|
|
42
24
|
loadMotionPlugin(e),
|
|
@@ -55,265 +37,13 @@ async function initPlugins(engine) {
|
|
|
55
37
|
loadWobbleUpdater(e),
|
|
56
38
|
]);
|
|
57
39
|
});
|
|
58
|
-
initializing = false;
|
|
59
|
-
initialized = true;
|
|
60
40
|
}
|
|
61
|
-
async function
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
let container;
|
|
65
|
-
const fpsLimit = 120, fpsLimitFactor = 3.6, opacitySpeed = (actualOptions.ticks * millisecondsToSeconds) / (fpsLimitFactor * millisecondsToSeconds * fpsLimit);
|
|
66
|
-
if (ids.has(params.id)) {
|
|
67
|
-
container = ids.get(params.id);
|
|
68
|
-
if (container && !container.destroyed) {
|
|
69
|
-
const alias = container;
|
|
70
|
-
if ("addEmitter" in alias) {
|
|
71
|
-
await alias.addEmitter?.({
|
|
72
|
-
startCount: actualOptions.count,
|
|
73
|
-
position: actualOptions.position,
|
|
74
|
-
size: {
|
|
75
|
-
width: 0,
|
|
76
|
-
height: 0,
|
|
77
|
-
},
|
|
78
|
-
rate: {
|
|
79
|
-
delay: 0,
|
|
80
|
-
quantity: 0,
|
|
81
|
-
},
|
|
82
|
-
life: {
|
|
83
|
-
duration: 0.1,
|
|
84
|
-
count: 1,
|
|
85
|
-
},
|
|
86
|
-
particles: {
|
|
87
|
-
fill: {
|
|
88
|
-
color: {
|
|
89
|
-
value: actualOptions.colors,
|
|
90
|
-
},
|
|
91
|
-
enable: true,
|
|
92
|
-
},
|
|
93
|
-
shape: {
|
|
94
|
-
type: actualOptions.shapes,
|
|
95
|
-
options: actualOptions.shapeOptions,
|
|
96
|
-
},
|
|
97
|
-
life: {
|
|
98
|
-
count: 1,
|
|
99
|
-
},
|
|
100
|
-
opacity: {
|
|
101
|
-
value: { min: 0, max: 1 },
|
|
102
|
-
animation: {
|
|
103
|
-
enable: true,
|
|
104
|
-
sync: true,
|
|
105
|
-
speed: opacitySpeed,
|
|
106
|
-
startValue: "max",
|
|
107
|
-
destroy: "min",
|
|
108
|
-
count: 1,
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
size: {
|
|
112
|
-
value: sizeFactor * actualOptions.scalar,
|
|
113
|
-
},
|
|
114
|
-
move: {
|
|
115
|
-
angle: {
|
|
116
|
-
value: actualOptions.spread,
|
|
117
|
-
offset: 0,
|
|
118
|
-
},
|
|
119
|
-
drift: {
|
|
120
|
-
min: -actualOptions.drift,
|
|
121
|
-
max: actualOptions.drift,
|
|
122
|
-
},
|
|
123
|
-
gravity: {
|
|
124
|
-
acceleration: actualOptions.gravity * defaultGravity,
|
|
125
|
-
},
|
|
126
|
-
speed: actualOptions.startVelocity * speedFactor,
|
|
127
|
-
decay: decayOffset - actualOptions.decay,
|
|
128
|
-
direction: -actualOptions.angle,
|
|
129
|
-
},
|
|
130
|
-
rotate: {
|
|
131
|
-
value: actualOptions.flat
|
|
132
|
-
? disableRotate
|
|
133
|
-
: {
|
|
134
|
-
min: 0,
|
|
135
|
-
max: 360,
|
|
136
|
-
},
|
|
137
|
-
direction: "random",
|
|
138
|
-
animation: {
|
|
139
|
-
enable: !actualOptions.flat,
|
|
140
|
-
speed: 60,
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
tilt: {
|
|
144
|
-
direction: "random",
|
|
145
|
-
enable: !actualOptions.flat,
|
|
146
|
-
value: actualOptions.flat
|
|
147
|
-
? disableTilt
|
|
148
|
-
: {
|
|
149
|
-
min: 0,
|
|
150
|
-
max: 360,
|
|
151
|
-
},
|
|
152
|
-
animation: {
|
|
153
|
-
enable: true,
|
|
154
|
-
speed: 60,
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
roll: {
|
|
158
|
-
darken: {
|
|
159
|
-
enable: true,
|
|
160
|
-
value: 25,
|
|
161
|
-
},
|
|
162
|
-
enable: !actualOptions.flat,
|
|
163
|
-
speed: {
|
|
164
|
-
min: 15,
|
|
165
|
-
max: 25,
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
wobble: {
|
|
169
|
-
distance: 30,
|
|
170
|
-
enable: !actualOptions.flat,
|
|
171
|
-
speed: {
|
|
172
|
-
min: -15,
|
|
173
|
-
max: 15,
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
});
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
41
|
+
async function initPlugins(engine) {
|
|
42
|
+
if (initPromise) {
|
|
43
|
+
return initPromise;
|
|
181
44
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
enable: !params.canvas,
|
|
185
|
-
zIndex: actualOptions.zIndex,
|
|
186
|
-
},
|
|
187
|
-
fpsLimit: 120,
|
|
188
|
-
particles: {
|
|
189
|
-
number: {
|
|
190
|
-
value: 0,
|
|
191
|
-
},
|
|
192
|
-
fill: {
|
|
193
|
-
color: {
|
|
194
|
-
value: actualOptions.colors,
|
|
195
|
-
},
|
|
196
|
-
enable: true,
|
|
197
|
-
},
|
|
198
|
-
shape: {
|
|
199
|
-
type: actualOptions.shapes,
|
|
200
|
-
options: actualOptions.shapeOptions,
|
|
201
|
-
},
|
|
202
|
-
opacity: {
|
|
203
|
-
value: { min: 0, max: 1 },
|
|
204
|
-
animation: {
|
|
205
|
-
enable: true,
|
|
206
|
-
sync: true,
|
|
207
|
-
speed: opacitySpeed,
|
|
208
|
-
startValue: "max",
|
|
209
|
-
destroy: "min",
|
|
210
|
-
count: 1,
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
size: {
|
|
214
|
-
value: sizeFactor * actualOptions.scalar,
|
|
215
|
-
},
|
|
216
|
-
links: {
|
|
217
|
-
enable: false,
|
|
218
|
-
},
|
|
219
|
-
life: {
|
|
220
|
-
count: 1,
|
|
221
|
-
},
|
|
222
|
-
move: {
|
|
223
|
-
angle: {
|
|
224
|
-
value: actualOptions.spread,
|
|
225
|
-
offset: 0,
|
|
226
|
-
},
|
|
227
|
-
drift: {
|
|
228
|
-
min: -actualOptions.drift,
|
|
229
|
-
max: actualOptions.drift,
|
|
230
|
-
},
|
|
231
|
-
enable: true,
|
|
232
|
-
gravity: {
|
|
233
|
-
enable: true,
|
|
234
|
-
acceleration: actualOptions.gravity * defaultGravity,
|
|
235
|
-
},
|
|
236
|
-
speed: actualOptions.startVelocity * speedFactor,
|
|
237
|
-
decay: decayOffset - actualOptions.decay,
|
|
238
|
-
direction: -actualOptions.angle,
|
|
239
|
-
random: true,
|
|
240
|
-
straight: false,
|
|
241
|
-
outModes: {
|
|
242
|
-
default: "none",
|
|
243
|
-
bottom: "destroy",
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
|
-
rotate: {
|
|
247
|
-
value: actualOptions.flat
|
|
248
|
-
? disableRotate
|
|
249
|
-
: {
|
|
250
|
-
min: 0,
|
|
251
|
-
max: 360,
|
|
252
|
-
},
|
|
253
|
-
direction: "random",
|
|
254
|
-
animation: {
|
|
255
|
-
enable: !actualOptions.flat,
|
|
256
|
-
speed: 60,
|
|
257
|
-
},
|
|
258
|
-
},
|
|
259
|
-
tilt: {
|
|
260
|
-
direction: "random",
|
|
261
|
-
enable: !actualOptions.flat,
|
|
262
|
-
value: actualOptions.flat
|
|
263
|
-
? disableTilt
|
|
264
|
-
: {
|
|
265
|
-
min: 0,
|
|
266
|
-
max: 360,
|
|
267
|
-
},
|
|
268
|
-
animation: {
|
|
269
|
-
enable: true,
|
|
270
|
-
speed: 60,
|
|
271
|
-
},
|
|
272
|
-
},
|
|
273
|
-
roll: {
|
|
274
|
-
darken: {
|
|
275
|
-
enable: true,
|
|
276
|
-
value: 25,
|
|
277
|
-
},
|
|
278
|
-
enable: !actualOptions.flat,
|
|
279
|
-
speed: {
|
|
280
|
-
min: 15,
|
|
281
|
-
max: 25,
|
|
282
|
-
},
|
|
283
|
-
},
|
|
284
|
-
wobble: {
|
|
285
|
-
distance: 30,
|
|
286
|
-
enable: !actualOptions.flat,
|
|
287
|
-
speed: {
|
|
288
|
-
min: -15,
|
|
289
|
-
max: 15,
|
|
290
|
-
},
|
|
291
|
-
},
|
|
292
|
-
},
|
|
293
|
-
motion: {
|
|
294
|
-
disable: actualOptions.disableForReducedMotion,
|
|
295
|
-
},
|
|
296
|
-
emitters: {
|
|
297
|
-
name: "confetti",
|
|
298
|
-
startCount: actualOptions.count,
|
|
299
|
-
position: actualOptions.position,
|
|
300
|
-
size: {
|
|
301
|
-
width: 0,
|
|
302
|
-
height: 0,
|
|
303
|
-
},
|
|
304
|
-
rate: {
|
|
305
|
-
delay: 0,
|
|
306
|
-
quantity: 0,
|
|
307
|
-
},
|
|
308
|
-
life: {
|
|
309
|
-
duration: 0.1,
|
|
310
|
-
count: 1,
|
|
311
|
-
},
|
|
312
|
-
},
|
|
313
|
-
};
|
|
314
|
-
container = await tsParticles.load({ id: params.id, element: params.canvas, options: particlesOptions });
|
|
315
|
-
ids.set(params.id, container);
|
|
316
|
-
return container;
|
|
45
|
+
initPromise = doInitPlugins(engine);
|
|
46
|
+
return initPromise;
|
|
317
47
|
}
|
|
318
48
|
export async function confetti(idOrOptions, confettiOptions) {
|
|
319
49
|
await initPlugins(tsParticles);
|
|
@@ -326,15 +56,20 @@ export async function confetti(idOrOptions, confettiOptions) {
|
|
|
326
56
|
id = "confetti";
|
|
327
57
|
options = idOrOptions;
|
|
328
58
|
}
|
|
329
|
-
return setConfetti({
|
|
59
|
+
return setConfetti(tsParticles, {
|
|
330
60
|
id,
|
|
331
61
|
options,
|
|
332
62
|
});
|
|
333
63
|
}
|
|
334
|
-
confetti.create = async (canvas, options) => {
|
|
64
|
+
confetti.create = async (canvas, options = {}) => {
|
|
335
65
|
await initPlugins(tsParticles);
|
|
336
|
-
const id = canvas
|
|
337
|
-
canvas
|
|
66
|
+
const id = canvas?.getAttribute("id") ?? "confetti";
|
|
67
|
+
canvas?.setAttribute("id", id);
|
|
68
|
+
await setConfetti(tsParticles, {
|
|
69
|
+
id,
|
|
70
|
+
canvas: canvas ?? undefined,
|
|
71
|
+
options,
|
|
72
|
+
});
|
|
338
73
|
return async (idOrOptions, confettiOptions) => {
|
|
339
74
|
let subOptions, subId;
|
|
340
75
|
if (isString(idOrOptions)) {
|
|
@@ -345,9 +80,9 @@ confetti.create = async (canvas, options) => {
|
|
|
345
80
|
subId = id;
|
|
346
81
|
subOptions = idOrOptions;
|
|
347
82
|
}
|
|
348
|
-
return setConfetti({
|
|
83
|
+
return setConfetti(tsParticles, {
|
|
349
84
|
id: subId,
|
|
350
|
-
canvas,
|
|
85
|
+
canvas: canvas ?? undefined,
|
|
351
86
|
options: subOptions,
|
|
352
87
|
});
|
|
353
88
|
};
|
|
@@ -355,5 +90,5 @@ confetti.create = async (canvas, options) => {
|
|
|
355
90
|
confetti.init = async () => {
|
|
356
91
|
await initPlugins(tsParticles);
|
|
357
92
|
};
|
|
358
|
-
confetti.version = "4.0.0
|
|
93
|
+
confetti.version = "4.0.0";
|
|
359
94
|
globalThis.confetti = confetti;
|