falling-animation 0.1.0 â 0.1.2
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 +151 -13
- package/dist/falling-animation.cjs +1036 -0
- package/dist/falling-animation.cjs.js +361 -12
- package/dist/falling-animation.cjs.js.map +1 -1
- package/dist/falling-animation.cjs.map +1 -0
- package/dist/falling-animation.esm.js +377 -13
- package/dist/falling-animation.esm.js.map +1 -1
- package/dist/falling-animation.umd.js +378 -12
- package/dist/falling-animation.umd.js.map +1 -1
- package/dist/falling-animation.umd.min.js +3 -2
- package/dist/falling-animation.umd.min.js.map +1 -1
- package/dist/types/Fireworks.d.ts +76 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/utils.d.ts +5 -0
- package/package.json +11 -3
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
|
|
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
|
[](https://www.npmjs.com/package/falling-animation)
|
|
6
6
|
[](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, <
|
|
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
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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'
|
|
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
|
-
|
|
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)
|