Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svelte-confetti-p5

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-confetti-p5

An awesome svelte realistic fullpage confetti animation, that can be customized in creative ways like snow flakes, falling balls and more.

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
decreased by-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

Netlify Status npm npm

DEMO | REPL

svelte-confetti-p5 🎊

svelte-confetti-p5 is an awesome svelte realistic fullpage confetti animation, that can be customized in creative ways like snow flakes, falling balls and more.


p5 what?

No CSS animations, but html Canvas created using P5.js (library for creative coding)

Thanks

  • Based on Tibo's work on Codepen, modified by me to easily control options using Svelte
  • We're using P5-svelte to make it work in svelte

Installation

# pnpm
pnpm i -D svelte-confetti-p5

pnpm is used here just as an example, you can use your package of choice

Usage

<script>
  import { ConfettiP5 } from "svelte-confetti-p5";
</script>

<ConfettiP5 />

Customize everything

Settings

PropTypeDescriptionDefault
amountnumberAmount of particles300
colorsstring[]Colors of the confetti. Default is very colorful["#f44336", "#e91e63", "#9c27b0", "#673ab7", "#3f51b5", "#2196f3", "#03a9f4", "#00bcd4", "#009688", "#4CAF50", "#8BC34A", "#CDDC39", "#FFEB3B", "#FFC107", "#FF9800", "#FF5722"]
minSizenumberMinimum particle size in pixels5
maxSizenumberMinimum particle size in pixels15
loopbooleanRain forever or until all particles fallfalse
spacingnumberSpacing between particles10
powernumberThe force of the confetti when it starts10
shapes"squares" | "circles" | "mix"Particle shapes"mix"
windnumberWind from sides6
weightnumberWeight of the particle (this determines the falling speed)100
rotatenumberRotate particles from side to side because of wind2
flipnumberFlip amount to create 3d effect for each particle20
position"fixed" | "absolute"Css position of the canvas"fixed"
zIndexnumberz-index of the canvas999
destoryOnFinishbooleanIf loop === false, destroys the canvas when all particles falltrue
frameRatenumberRefresh rate. Changing this will affect the overall speed of the animation. Recommended to keep as default60

Dispatchers

DispatcherDescriptionevent returns
on:startFires when the confetti animation starts-
on:eachfallFires when a single confetti particle has falledon:eachfall=(e => e.detail) returns the total amount of particles falled
on:doneFires when all confetti particles fall-
on:destroyFires when the canvas is destroyed, automaticlly happens when all particles finished falling-

Examples

Nice and slow

<ConfettiP5
  on:eachfall={onEachFall}
  on:start={onStart}
  on:done={onDone}
  on:destory={onDestroy}
  loop
  colors={["#fbfefd", "#00186a", "#003afb", "#7aa8f7"]}
  amount={120}
  minSize={5}
  maxSize={15}
  spacing={15}
  flip={3}
  wind={0}
  weight={100}
  rotate={3}
  power={0}
/>

Snow flakes:

<ConfettiP5
  on:eachfall={onEachFall}
  on:start={onStart}
  on:done={onDone}
  on:destory={onDestroy}
  colors={["#e7edf3", "#e4f3ff", "#b9e1ff", "#a6d9ff"]}
  shapes="circles"
  minSize={0}
  maxSize={14}
  spacing={5}
  amount={50}
  flip={0}
  wind={0}
  power={2}
  weight={50}
/>

More examples here

Playground here

Used by

ConfettiPage.io

License

MIT license


Publishing

(Dev note): To publish this library to npm:

pnpm publish

Keywords

FAQs

Package last updated on 22 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc