Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/daniel-lundin/react-dom-confetti
Trigger confetti explosions on state transitions
https://github.com/daniel-lundin/react-dom-confetti
Last synced: 5 days ago
JSON representation
Trigger confetti explosions on state transitions
- Host: GitHub
- URL: https://github.com/daniel-lundin/react-dom-confetti
- Owner: daniel-lundin
- Created: 2017-04-16T22:05:29.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T16:24:09.000Z (almost 2 years ago)
- Last Synced: 2024-10-31T14:43:11.709Z (13 days ago)
- Language: JavaScript
- Size: 745 KB
- Stars: 624
- Watchers: 3
- Forks: 30
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-dom-confetti
[![npm version](https://badge.fury.io/js/react-dom-confetti.svg)](https://www.npmjs.com/package/react-dom-confetti)
Trigger confetti explosions on state transitions:
```js
import Confetti from 'react-dom-confetti';// in render
```
This component will trigger a confetti explosion every time the prop `active` goes from a falsy to truthy value.
## Demo
[https://daniel-lundin.github.io/react-dom-confetti/](https://daniel-lundin.github.io/react-dom-confetti/)## Why?
Slow operations annoy users and stakeholders. We have two options, either optimize slow operations or **make it worth the wait**. This library focuses on the latter.### Props
#### active
Required. Triggers an explosion when the prop transitions from falsy to truthy.
#### config
Optional. Configuration object to control the characteristics of the confetti:
- `angle` - direction of the explosion in degrees, defaults to 90.
- `spread` - spread of the explosion in degrees, defaults to 45.
- `startVelocity` - Initial velocity of the particles, defaults to 45.
- `width`: - width of the confetti elements
- `height`: - height of the confetti elements
- `elementCount` - Number of particle elements, defaults to 50.
- `decay` - *deprecated* - Decrease in velocity per frame, defaults to 0.9 (Use of this will disable dragFriction)
- `dragFriction` - Decrease in velocity proportional to current velocity, default to 0.1
- `delay` - *deprecated* Use stagger instead.
- `stagger` - Delay for each fetti in milliseconds, defaults to 0.
- `random` - Randomization function, defaults to Math.random
- `colors` - An array of color codes, defaults to `['#a864fd', '#29cdff', '#78ff44', '#ff718d' '#fdff6a']`License MIT, copyright [Daniel Lundin](https://www.twitter.com/daniel-lundin) 2017