npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

confetti-explosion-react

v0.1.2

Published

A React lightweight css-animation based confetti exploder

Downloads

2,473

Readme

React Confetti Explosion

npm version

This package is a fork from herrethan package react-confetti-explosion to support React 18 and to update dependencies.

From the original project:

This is inspired by this beautiful and oft-used confetti which uses canvas, but equally inspired by how many bad looking CSS examples there are out there. The goal was to create a super lightweight confetti component that would not require canvas, use only CSS for animation, and could also be controlled as an explosion (rather than raining confetti), without the need to write a full-blown particle generator.

Install:

$ npm install confetti-explosion-react
$ yarn add confetti-explosion-react

Usage

import ConfettiExplosion from 'confetti-explosion-react';

function App() {
  const [isExploding, setIsExploding] = React.useState(false);
  return <>{isExploding && <ConfettiExplosion />}</>;
}

Optional Props

| Name | Type | Default | Description | | ------------- | ---------- | ------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | | particleCount | number | 150 | Total number of particles used. Generally try to stay under 400 for optimal performance. | | particleSize | number | 12 | Size of particles in pixels. This means width for squares, diameter for circles. Note there is also a bit of randomness added to these. | | duration | number | 3500 | Duration of explosion in ms. This is the time it takes particles to travel from explosion point to the floor, as defined by height. | | colors | string[] | ['#FFC700','#FF0000','#2E3191','#41BBC7'] | An array of any css-readable colors, which are evenly distributed across the number of total particles. | | force | number | 0.5 | Between 0-1, roughly the vertical force at which particles initially explode. Straying too far away from 0.5 may start looking...interesting. | | height | number | 800 | Pixel distance the particles will vertically spread from initial explosion point. | | width | number | 1600 | Pixel distance the particles will horizontally spread from initial explosion point. | |

Although the duration of the explosion is controlled, it is up to the consumer how and when the ConfettiExplosion is rendered and positioned (and, hey, maybe even faded out?).

Potential gotchas

  • Your container must be full 100% width/height for all particles to be seen, but overflow: hidden to avoid having particles create scrollbars.
  • If your height is too small, particles may visibly land on the floor instead of disappearing off-screen.

To keep the library as little as possible much of the physics have been estimated, cheapened, and downright mutilated. There are certainly prop combinations that will not look realistic, due to the limitations of CSS animations. But there should be enough options to fit most needs.

Example Screenshots

Big explosion

{
  force: 0.6,
  duration: 5000,
  particleCount: 200,
  height: 1600,
  width: 1600
}

confetti-large-edit

Little explosion

{
  force: 0.4,
  duration: 3000,
  particleCount: 60,
  height: 1000,
  width: 1000
}

confetti-small-edit

Tiny explosion

{
  force: 0.4,
  duration: 2000,
  particleCount: 30,
  height: 500,
  width: 300
}

confetti-tiny

Author

DercilioFontes based on herrethan work

License

MIT