kylefox / dom-confetti

Celebrate success with dom confetti!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dom-confetti

npm version

Trigger confetti explosions in the DOM.

import confetti from 'dom-confetti';

const button = document.querySelector(".my-button")
button.addEventListener("click", () => confetti(button))

This will trigger a confetti explosion every time a button is clicked.

Demo

https://daniel-lundin.github.io/react-dom-confetti/

Interface

confetti`(root, config = {})

root should be the DOM element to start the explosion at, and config, if given, may be an object specifying the following options:

  • angle - direction of the explosion in degrees, defaults to 90.
  • spread - spread of the explosion in degrees, deafults to 45.
  • startVelocity - Initial velocity of the particles, defaults to 45.
  • elementCount - Number of particle elements, default to 50.
  • decay - Decrease in velocity per frame, defaults to 0.9

License MIT, copyright Daniel Lundin 2017

About

Celebrate success with dom confetti!


Languages

Language:JavaScript 77.5%Language:HTML 20.0%Language:CSS 2.5%