All Projects → loonywizard → js-confetti

loonywizard / js-confetti

Licence: MIT License
JS Confetti library that supports emojis 🦄 🎉 ⚡️

Programming Languages

typescript
32286 projects
CSS
56736 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to js-confetti

Canvas Confetti
🎉 on-demand confetti gun
Stars: ✭ 2,394 (+597.96%)
Mutual labels:  canvas, confetti, canvas-confetti
canvas-td
A fully featured tower defense game built with <canvas>.
Stars: ✭ 31 (-90.96%)
Mutual labels:  canvas
drawing-board
canvas-drawing-board
Stars: ✭ 23 (-93.29%)
Mutual labels:  canvas
maze-generator
A real-time JavaScript maze generator using the depth-first search algorithm
Stars: ✭ 13 (-96.21%)
Mutual labels:  canvas
turkeyvisited
Mark the cities you have visited in Turkey and share the map!
Stars: ✭ 82 (-76.09%)
Mutual labels:  canvas
TakingImageOfAView
An example on how to take screenshot of a particular view
Stars: ✭ 15 (-95.63%)
Mutual labels:  canvas
idraw
A simple JavaScript framework for Drawing on the web.(一个面向Web绘图的JavaScript框架)
Stars: ✭ 436 (+27.11%)
Mutual labels:  canvas
d3-canvas-transition
transition on canvas with d3
Stars: ✭ 19 (-94.46%)
Mutual labels:  canvas
awesome-canvas
Canvas资源库大全中文版。An awesome Canvas packages and resources.
Stars: ✭ 288 (-16.03%)
Mutual labels:  canvas
jmonet
An easy-to-use toolkit for incorporating MacPaint / Microsoft Paint-like tools into a Java Swing or JavaFX application.
Stars: ✭ 27 (-92.13%)
Mutual labels:  canvas
vueShop
🙂collections
Stars: ✭ 72 (-79.01%)
Mutual labels:  canvas
lottery-rotate
适配移动端rem布局的canvas大转盘抽奖插件
Stars: ✭ 15 (-95.63%)
Mutual labels:  canvas
okeevis-render
a fast lightweight 2d graphic library
Stars: ✭ 22 (-93.59%)
Mutual labels:  canvas
empathy-map
チームでお互いのことを知り、ゴールや目的を共有する。
Stars: ✭ 15 (-95.63%)
Mutual labels:  canvas
city-tour
A procedurally generated city built with WebGL and three.js
Stars: ✭ 57 (-83.38%)
Mutual labels:  canvas
canvas-constructor
An ES6 utility for canvas with built-in functions and chained methods.
Stars: ✭ 96 (-72.01%)
Mutual labels:  canvas
img-clipping
基于Canvas的一个h5移动端图片裁剪demo
Stars: ✭ 81 (-76.38%)
Mutual labels:  canvas
huozi.js
A simple typography engine for CJK languages, especially designed for game rich-text. 用于游戏富文本的中日韩文字排印引擎。
Stars: ✭ 135 (-60.64%)
Mutual labels:  canvas
pikaso
Seamless and headless HTML5 Canvas library
Stars: ✭ 23 (-93.29%)
Mutual labels:  canvas
react-starfield-animation
✨ Canvas-based starfield animation for React.
Stars: ✭ 82 (-76.09%)
Mutual labels:  canvas

npm version NPM Downloads npm bundle size

🎉 JavaScript Confetti library

💥 Supports emojis as confetti
⚡️ Zero dependencies used
🦄 Works without any config, yet configurable
🛠 Has TypeScript typings
🧩 Confetti speed adapts to user screen width

Links: GitHub | NPM | Demo

Install

You can install library from NPM using yarn or npm

yarn add js-confetti

Alternatively you can download script from CDN

<script src="https://cdn.jsdelivr.net/npm/js-confetti@latest/dist/js-confetti.browser.js"></script>

and then access JSConfetti global variable

Usage

Initialize instance of JSConfetti class and call addConfetti method

import JSConfetti from 'js-confetti'

const jsConfetti = new JSConfetti()

jsConfetti.addConfetti()

NOTE new JSConfetti() creates HTML Canvas element and adds it to page, so call it only once!

If need to use custom canvas element, you can pass canvas arg to JSConfetti constructor (example)

const canvas = document.getElementById('your_custom_canvas_id')

const jsConfetti = new JSConfetti({ canvas })

Customise confetti

Use emojis as confetti:

jsConfetti.addConfetti({
   emojis: ['🌈', '⚡️', '💥', '✨', '💫', '🌸'],
})

Customize confetti colors:

jsConfetti.addConfetti({
  confettiColors: [
    '#ff0a54', '#ff477e', '#ff7096', '#ff85a1', '#fbb1bd', '#f9bec7',
  ],
})

Customize confetti radius:

jsConfetti.addConfetti({
  confettiRadius: 6,
})

Customize confetti number:

jsConfetti.addConfetti({
  confettiRadius: 6,
  confettiNumber: 500,
})

Combine different properties:

jsConfetti.addConfetti({
  emojis: ['🦄'],
  emojiSize: 100,
  confettiNumber: 30,
})

addConfetti Promise

addConfetti method returns Promise, which is resolved when added confetti dissapears from the user screen due to the gravity physics of confetti

Example:

// async/await
await jsConfetti.addConfetti()
console.log('Confetti animation completed!')

// Promise.then
jsConfetti.addConfetti()
   .then(() => console.log('Confetti animation completed!'))

How to run locally

Install dependencies by Yarn or NPM

yarn install

Run dev script with website build

yarn run dev

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].