falling-animation 0.1.2 → 0.1.4
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 +74 -23
- package/dist/falling-animation.cjs +598 -207
- package/dist/falling-animation.esm.js +598 -207
- package/dist/falling-animation.umd.js +598 -207
- package/dist/falling-animation.umd.min.js +2 -3
- package/dist/types/CanvasRenderer.d.ts +78 -0
- package/dist/types/FallingAnimation.d.ts +6 -6
- package/dist/types/Fireworks.d.ts +40 -5
- package/dist/types/Particle.d.ts +5 -17
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types.d.ts +4 -2
- package/package.json +2 -2
- package/dist/falling-animation.cjs.js +0 -1019
- package/dist/falling-animation.cjs.js.map +0 -1
- package/dist/falling-animation.cjs.map +0 -1
- package/dist/falling-animation.esm.js.map +0 -1
- package/dist/falling-animation.umd.js.map +0 -1
- package/dist/falling-animation.umd.min.js.map +0 -1
package/README.md
CHANGED
|
@@ -276,16 +276,16 @@ interface FireworksOptions {
|
|
|
276
276
|
// Colors for fireworks (default: 10 festive colors)
|
|
277
277
|
colors?: string[];
|
|
278
278
|
|
|
279
|
-
// Rockets per second (default:
|
|
279
|
+
// Rockets per second (default: 0.5)
|
|
280
280
|
launchRate?: number;
|
|
281
281
|
|
|
282
282
|
// Particles per explosion (default: 50)
|
|
283
283
|
particlesPerExplosion?: number;
|
|
284
284
|
|
|
285
|
-
// Rocket speed range (default: { min:
|
|
285
|
+
// Rocket speed range (default: { min: 7, max: 12 })
|
|
286
286
|
rocketSpeed?: { min: number; max: number };
|
|
287
287
|
|
|
288
|
-
// Explosion particle speed (default: { min:
|
|
288
|
+
// Explosion particle speed (default: { min: 1, max: 6 })
|
|
289
289
|
explosionSpeed?: { min: number; max: number };
|
|
290
290
|
|
|
291
291
|
// Particle size in px (default: { min: 2, max: 6 })
|
|
@@ -300,6 +300,11 @@ interface FireworksOptions {
|
|
|
300
300
|
// Auto start (default: true)
|
|
301
301
|
autoStart?: boolean;
|
|
302
302
|
|
|
303
|
+
// Explosion pattern (default: 'random')
|
|
304
|
+
// Values: 'random' | 'circular' | 'double' | 'embers' | 'heart' | 'star' | 'ring' | 'palm' | 'willow' | 'chrysanthemum'
|
|
305
|
+
// Can also be an array: ['double', 'heart']
|
|
306
|
+
explosionPattern?: ExplosionPattern | ExplosionPattern[];
|
|
307
|
+
|
|
303
308
|
// Z-index (default: 9999)
|
|
304
309
|
zIndex?: number;
|
|
305
310
|
}
|
|
@@ -333,49 +338,93 @@ fw.getIsRunning();
|
|
|
333
338
|
|
|
334
339
|
### Fireworks Examples
|
|
335
340
|
|
|
336
|
-
|
|
341
|
+
### Explosion Patterns
|
|
342
|
+
|
|
343
|
+
You can choose from 9 different explosion patterns or use a random mix!
|
|
344
|
+
|
|
345
|
+
- `random`: Randomly selects a pattern for each explosion (default)
|
|
346
|
+
- `circular`: Standard circular explosion
|
|
347
|
+
- `double`: **Spectacular 2-stage explosion** (particles explode again!)
|
|
348
|
+
- `waterfall`: **Waterfall effect** (gentle up, heavy rain down)
|
|
349
|
+
- `embers`: Slow-falling, micro-particles (Tàn Lửa)
|
|
350
|
+
- `heart`: ❤️ Heart shape
|
|
351
|
+
- `star`: ⭐ Star shape
|
|
352
|
+
- `ring`: 💍 Ring shape
|
|
353
|
+
- `palm`: 🌴 Palm tree effect
|
|
354
|
+
- `willow`: 🌳 Trailing willow effect
|
|
355
|
+
- `chrysanthemum`: 🌼 Dense spherical burst
|
|
356
|
+
|
|
357
|
+
### ✨ Recommended Presets
|
|
358
|
+
|
|
359
|
+
Here are some beautiful configurations to get you started:
|
|
360
|
+
|
|
361
|
+
#### 1. The Grand Finale (Spectacular Mix)
|
|
362
|
+
Perfect for big celebrations. Uses double explosions and a mix of random patterns.
|
|
337
363
|
|
|
338
364
|
```javascript
|
|
339
|
-
|
|
365
|
+
const fireworks = new Fireworks({
|
|
366
|
+
launchRate: 2,
|
|
367
|
+
particlesPerExplosion: 50,
|
|
368
|
+
explosionPattern: ['double', 'random'], // Mix of single and double explosions
|
|
369
|
+
rocketSpeed: { min: 12, max: 18 },
|
|
370
|
+
explosionSpeed: { min: 3, max: 9 }
|
|
371
|
+
});
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
#### 2. Romantic Hearts
|
|
375
|
+
A gentle stream of heart-shaped fireworks, great for weddings or Valentine's.
|
|
340
376
|
|
|
377
|
+
```javascript
|
|
341
378
|
new Fireworks({
|
|
342
|
-
launchRate:
|
|
343
|
-
particlesPerExplosion:
|
|
379
|
+
launchRate: 1,
|
|
380
|
+
particlesPerExplosion: 40,
|
|
381
|
+
explosionPattern: 'heart',
|
|
382
|
+
colors: ['#ff0000', '#ff69b4', '#ffffff'], // Red, Pink, White
|
|
383
|
+
gravity: 0.05, // Slower fall
|
|
384
|
+
rocketSpeed: { min: 10, max: 12 }
|
|
344
385
|
});
|
|
345
386
|
```
|
|
346
387
|
|
|
347
|
-
####
|
|
388
|
+
#### 3. Gentle Embers (Tàn Lửa)
|
|
389
|
+
Soft, floating micro-particles that drift slowly. Very atmospheric.
|
|
348
390
|
|
|
349
391
|
```javascript
|
|
350
392
|
new Fireworks({
|
|
351
|
-
|
|
352
|
-
|
|
393
|
+
launchRate: 3,
|
|
394
|
+
explosionPattern: 'embers',
|
|
395
|
+
rocketSpeed: { min: 8, max: 12 },
|
|
396
|
+
particleLifetime: { min: 2000, max: 4000 },
|
|
397
|
+
gravity: 0.05
|
|
353
398
|
});
|
|
354
399
|
```
|
|
355
400
|
|
|
356
|
-
#### New Year
|
|
401
|
+
#### 4. New Year Countdown (Intense)
|
|
402
|
+
High density, fast-paced action!
|
|
357
403
|
|
|
358
404
|
```javascript
|
|
359
405
|
const fw = new Fireworks({
|
|
360
|
-
launchRate:
|
|
361
|
-
particlesPerExplosion:
|
|
362
|
-
|
|
363
|
-
|
|
406
|
+
launchRate: 4, // Fast launch
|
|
407
|
+
particlesPerExplosion: 60, // Dense explosions
|
|
408
|
+
explosionPattern: 'random',
|
|
409
|
+
explosionSpeed: { min: 5, max: 10 }
|
|
364
410
|
});
|
|
365
411
|
|
|
366
|
-
// Launch a burst
|
|
367
|
-
fw.burst(
|
|
412
|
+
// Launch a massive burst manually when the timer hits zero!
|
|
413
|
+
// fw.burst(15);
|
|
368
414
|
```
|
|
369
415
|
|
|
370
|
-
####
|
|
416
|
+
#### 5. Single Shot (Manual Control)
|
|
417
|
+
Want to trigger fireworks manually (e.g., on button click)?
|
|
371
418
|
|
|
372
419
|
```javascript
|
|
373
|
-
new Fireworks({
|
|
374
|
-
|
|
375
|
-
launchRate: 0.5,
|
|
376
|
-
particlesPerExplosion: 30,
|
|
377
|
-
zIndex: 100
|
|
420
|
+
const fw = new Fireworks({
|
|
421
|
+
autoStart: false // 1. Disable auto-start
|
|
378
422
|
});
|
|
423
|
+
|
|
424
|
+
// 2. Trigger manually whenever you want (e.g. onClick)
|
|
425
|
+
fw.launch(); // Launches 1 rocket
|
|
426
|
+
// or
|
|
427
|
+
fw.burst(5); // Launches 5 rockets at once
|
|
379
428
|
```
|
|
380
429
|
|
|
381
430
|
---
|
|
@@ -387,3 +436,5 @@ MIT © [phongdh](https://github.com/phongdh)
|
|
|
387
436
|
## 🙏 Contributing
|
|
388
437
|
|
|
389
438
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
439
|
+
|
|
440
|
+
> I'm currently figuring out how to implement the **Waterfall** or **Weeping Willow** effect properly. If you have experience with these physics/visuals, I'd love your help! Please feel free to open a Pull Request.
|