0.3.4 • Published 2 months ago

confettis v0.3.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Confettis

NPM GitHub Issues GitHub Tag GitHub Commits GitHub License

🎉 Confettis v0.3.4

Confettis is a small lib to add confettis to your website. Yep, confettis! 🎉

  • 😊 SSR Support
  • 🎉 Common confettis
  • 👽 Emoji coffetis
  • ⭐️ Star confettis
  • 🟡 Circle confettis (snow?)
  • ✨ Confettis with different sizes
  • 🗿 Static or moving confettis
  • 😄 Super easy to use!

Demo

confettis.ovni.dev

Resources

Installation

Browser:

<script src="https://cdn.jsdelivr.net/npm/confettis@0.3.4/lib/confettis.min.js"></script>

Deno:

import * as confetti from 'https://esm.sh/confettis@0.3.4'

Node:

$ npm i confettis
import * as confetti from 'confettis'

Usage

Basic usage

confetti.create()

Advanced usage

confetti.create({
    x: 0.5,
    y: 0.7,
    count: 500,
    ticks: -1,
    gravity: [ 0.7, 1.2 ],
    speed: [ 35, 45 ],
    scale: [ 0.7, 0.8 ],
    decay: 0.91,
    shapes: [ 'square', 'ellipse' ]
})

This is just an example, but you can do anything. I recommend you look at the examples I have put on the web! See more examples here!

Parameters

When creating a new confetti you can change the parameters to change the position, particle count, angle, gravity, etc.

OptionTypeDefaultDescription
canvasstringconfettisId of canvas where you are going to show the confetti. If you do not put anything, a canvas will be created with id "confettis".
countnumber100Number of confetti to launch. Remember that the more particles the web performance will be worse. The recommended is between 1 and 300 particles per second.
xnumber0.5The X position is horizontal, being 0 the left edge and 1 the right edge.
ynumber0.7The Y position is vertical, being 0 the upper edge and 1 the lower edge.
znumberMAX_SAFE_INTEGERThe Z position on the page (z-index). Determine whether it is shown above or below other web elements. The higher the number, it will be shown above all (recommended). Default is Number.MAX_SAFE_INTEGER (2147483647) to overcome the height of most popular UI libs.
gravitynumber or [number]1Gravity determine how quickly the confetti will fall. You can play with this parameter to make it fall faster or slower, and you can even make the confetti rise up.
ticksnumber or [number]300Time that confetti will take to disappear (opacity). The higher the number, it will take longer to disappear. Put it in -1 to deactivate it and make it always visible.
speednumber or [number]45Speed with which the confetti will begin to move.
scalenumber or [number]0.8Scale factor for each confetti particle. Use decimals to make the confetti smaller. Example: 0.8, 1, 1.3
overflowobjectPrarameter to allow confetti particle exceed the canvas without being deleted
overflow.leftbooleanfalseWhen set to true allows the left overflow
overflow.rightbooleanfalseWhen set to true allows the right overflow
overflow.topbooleantrueWhen set to true allows the top overflow
overflow.bottombooleanfalseWhen set to true allows the bottom overflow
decaynumber0.92Determine the speed with which the confetti will lose speed. Keep this number between 0 and 1 so that the confetti does not go to the speed of light.
driftnumber0Determine the side where the confetti will go. 0 indicates that it will fall down. A negative number indicates that it will go to the left, and a positive number indicates that it will go to the right.
anglenumber90The angle at which the confetti is going to be released. In degrees (0-360)
spreadnumber70How far the confetti can come. In degrees (0-360)
quietbooleanfalseIt allows to create static confetti. Perfect if you want square or ellipse confetti without moving when falling.
colors[string]Array with strings of the colors you want to show the confetti. The colors must be in Hex format (#ffffff).
shapes[string]An array of shapes for the confetti.
emojis[string]An array of emojis for the confetti.

Accepted shapes

ShapeDescription
squareCreate common square confetti.
ellipseCreate confetti in the form of ellipse.
circleCreate confetti in the form of a circle.
starCreate confetti in the form of star with five spikes.
emojiCreate confetti with emojis.

Contributors

All issue reports, feature requests, pull requests and github stars are welcomed and much appreciated.

Thanks

Special thanks to catdad for canvas-confetti. I have created this project as inspiration to obtain a cleaner and legible code in typescript, and add extra functions.

0.3.1

2 months ago

0.3.4

2 months ago

0.3.3

2 months ago

0.3.0

7 months ago

0.2.8

7 months ago

0.2.7

7 months ago

0.2.6

7 months ago

0.2.5

7 months ago

0.2.4

7 months ago

0.2.3

7 months ago

0.2.0

7 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago