falling-animation 0.1.0 → 0.1.1

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
@@ -1,6 +1,6 @@
1
1
  # 🎉 Falling Animation
2
2
 
3
- A lightweight, customizable falling objects animation library for the web. Create beautiful falling effects like snow, leaves, confetti, and more!
3
+ A lightweight, customizable falling objects animation library for the web. Create beautiful falling effects like snow, leaves, confetti, and realistic fireworks!
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/falling-animation.svg)](https://www.npmjs.com/package/falling-animation)
6
6
  [![bundle size](https://img.shields.io/bundlephobia/minzip/falling-animation)](https://bundlephobia.com/package/falling-animation)
@@ -8,9 +8,10 @@ A lightweight, customizable falling objects animation library for the web. Creat
8
8
 
9
9
  ## âœĻ Features
10
10
 
11
- - ðŸŠķ **Lightweight** - No dependencies, < 10KB gzipped
11
+ - ðŸŠķ **Lightweight** - No dependencies, < 15KB gzipped
12
12
  - ðŸŽĻ **Customizable** - Full control over speed, size, animation, and more
13
13
  - 🎭 **8 Animation Types** - fall, swing, rotate, flutter, spiral, tumble, zigzag, float
14
+ - 🎆 **Fireworks** - Realistic rockets shooting up and exploding into colorful particles
14
15
  - ðŸ“ą **Responsive** - Automatically adapts to container size
15
16
  - 🖞ïļ **Multiple Object Types** - Emojis, images, or custom HTML
16
17
  - ⚡ **Performant** - Uses requestAnimationFrame and CSS transforms
@@ -227,21 +228,158 @@ new FallingAnimation({
227
228
  Full TypeScript support with exported types:
228
229
 
229
230
  ```typescript
230
- import {
231
- FallingAnimation,
232
- FallingAnimationOptions,
233
- FallingObject,
234
- AnimationType
235
- } from 'falling-animation';
236
-
237
- const options: FallingAnimationOptions = {
231
+ // For falling effects only
232
+ import { FallingAnimation, FallingAnimationOptions } from 'falling-animation';
233
+
234
+ const falling = new FallingAnimation({
238
235
  objects: [{ type: 'emoji', content: '🌟' }],
239
- animation: 'rotate' as AnimationType
240
- };
236
+ animation: 'rotate'
237
+ });
238
+ ```
239
+
240
+ ```typescript
241
+ // For fireworks only
242
+ import { Fireworks, FireworksOptions } from 'falling-animation';
243
+
244
+ const fw = new Fireworks({
245
+ launchRate: 2,
246
+ particlesPerExplosion: 60
247
+ });
248
+ ```
249
+
250
+ ```typescript
251
+ // Both together
252
+ import { FallingAnimation, Fireworks } from 'falling-animation';
253
+ ```
254
+
255
+ ---
256
+
257
+ ## 🎆 Fireworks
258
+
259
+ Create realistic firework effects with rockets shooting up and exploding into colorful particles!
260
+
261
+ ### Quick Start
262
+
263
+ ```javascript
264
+ import { Fireworks } from 'falling-animation';
265
+
266
+ const fireworks = new Fireworks();
267
+ ```
268
+
269
+ ### Fireworks Options
270
+
271
+ ```typescript
272
+ interface FireworksOptions {
273
+ // Container element or selector (default: document.body)
274
+ container?: HTMLElement | string;
275
+
276
+ // Colors for fireworks (default: 10 festive colors)
277
+ colors?: string[];
278
+
279
+ // Rockets per second (default: 1)
280
+ launchRate?: number;
281
+
282
+ // Particles per explosion (default: 50)
283
+ particlesPerExplosion?: number;
284
+
285
+ // Rocket speed range (default: { min: 8, max: 15 })
286
+ rocketSpeed?: { min: number; max: number };
287
+
288
+ // Explosion particle speed (default: { min: 2, max: 8 })
289
+ explosionSpeed?: { min: number; max: number };
290
+
291
+ // Particle size in px (default: { min: 2, max: 6 })
292
+ particleSize?: { min: number; max: number };
293
+
294
+ // Particle lifetime in ms (default: { min: 1000, max: 2000 })
295
+ particleLifetime?: { min: number; max: number };
296
+
297
+ // Gravity strength (default: 0.1)
298
+ gravity?: number;
299
+
300
+ // Auto start (default: true)
301
+ autoStart?: boolean;
302
+
303
+ // Z-index (default: 9999)
304
+ zIndex?: number;
305
+ }
306
+ ```
307
+
308
+ ### Fireworks Methods
309
+
310
+ ```javascript
311
+ const fw = new Fireworks();
241
312
 
242
- const falling = new FallingAnimation(options);
313
+ // Control methods
314
+ fw.start(); // Start continuous fireworks
315
+ fw.stop(); // Stop launching new rockets
316
+ fw.clear(); // Clear all particles
317
+ fw.destroy(); // Clean up completely
318
+
319
+ // Manual launch
320
+ fw.launch(); // Launch single firework
321
+ fw.burst(5); // Launch 5 fireworks at once
322
+
323
+ // Update options dynamically
324
+ fw.setOptions({
325
+ launchRate: 2,
326
+ particlesPerExplosion: 80
327
+ });
328
+
329
+ // Get state
330
+ fw.getParticleCount();
331
+ fw.getIsRunning();
332
+ ```
333
+
334
+ ### Fireworks Examples
335
+
336
+ #### Basic Fireworks Show
337
+
338
+ ```javascript
339
+ import { Fireworks } from 'falling-animation';
340
+
341
+ new Fireworks({
342
+ launchRate: 2,
343
+ particlesPerExplosion: 60
344
+ });
243
345
  ```
244
346
 
347
+ #### Custom Colors
348
+
349
+ ```javascript
350
+ new Fireworks({
351
+ colors: ['#ff0000', '#00ff00', '#0000ff', '#ffff00'],
352
+ launchRate: 1.5
353
+ });
354
+ ```
355
+
356
+ #### New Year Celebration
357
+
358
+ ```javascript
359
+ const fw = new Fireworks({
360
+ launchRate: 3,
361
+ particlesPerExplosion: 100,
362
+ gravity: 0.15,
363
+ particleLifetime: { min: 1500, max: 2500 }
364
+ });
365
+
366
+ // Launch a burst at midnight!
367
+ fw.burst(10);
368
+ ```
369
+
370
+ #### Bounded Container
371
+
372
+ ```javascript
373
+ new Fireworks({
374
+ container: '#celebration-box',
375
+ launchRate: 0.5,
376
+ particlesPerExplosion: 30,
377
+ zIndex: 100
378
+ });
379
+ ```
380
+
381
+ ---
382
+
245
383
  ## 📄 License
246
384
 
247
385
  MIT ÂĐ [phongdh](https://github.com/phongdh)