0.2.2 • Published 4 years ago

dom-confetti v0.2.2

Weekly downloads
49,742
License
MIT
Repository
github
Last release
4 years ago

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, defaults to 45.
  • startVelocity - Initial velocity of the particles, defaults to 45.
  • width: - width of the confetti elements as css string, defaults to 10px.
  • height: - height of the confetti elements as css string, defaults to 10px.
  • perspective - perspective of root element.
  • 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
  • duration - Duration in milliseconds, defaults to 3000
  • 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']

Returns a promise that resolves once the confetti has completed its fade out.

License MIT, copyright Daniel Lundin 2019

0.2.0

4 years ago

0.2.2

4 years ago

0.1.2

4 years ago

0.1.1

5 years ago

0.2.0-beta.5

5 years ago

0.2.0-beta.4

5 years ago

0.2.0-beta.3

5 years ago

0.2.0-beta.2

5 years ago

0.2.0-beta.1

5 years ago

0.1.0

5 years ago

0.1.0-alpha1

5 years ago

0.1.0-alpha

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago