Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

party-js

yiliansource69.8kMIT2.2.0TypeScript support: included

A JavaScript library to brighten up your user's site experience with visual effects!

party, confetti, particles

readme

InstallationUsageContributing

npm GitHub Repo stars GitHub Build Status GitHub Docs Status npm downloads

Installation

The library is written in TypeScript and compiled to an UMD module to allow integration into different environments.

Browsers

You can grab the latest version from jsdelivr.

<script src="https://cdn.jsdelivr.net/npm/party-js@latest/bundle/party.min.js"></script>

The library instance is loaded into the global party object.

Node.JS

If you are using a package-managed environment, you can also install the latest version via npm.

npm install party-js
# or
yarn add party-js

To use it, simply require or import it.

import party from "party-js";
// or
const party = require("party-js");

Usage

The library essentially offers a fully customizeable particle-system implementation into HTML documents. Users of the library have the ability to create and fine-tune effects to their individual liking. The library offers a few simple effects right out-of-the-box, so you don't have to waste time re-creating simple effects.

document.querySelector(".button").addEventListener("click", function (e) {
    party.confetti(this, {
        count: party.variation.range(20, 40),
    });
});

If you want to learn more, check out the quick start guide!

Known Issues

  • "The particles are getting cut off inside the screen!"
    When creating the particle container, the library calculates the document <body>'s size once. If your document size changes during the lifetime of your application you can either:

    1. Remove the #party-js-container. This forces the library to re-initialize the container and will re-calculate the size. All particles will remain in memory, so nothing will be lost.
    2. Manually calculate the needed container size and update it yourself. The library does not do this on a per-frame basis, in order not to unvoluntarily slow down older devices with timeout polling, and watching for document size changes is an expensive task, as of writing.

Contributing

First of all, thank you so much for wanting to contribute to the project! ❤
Please refer to the contribution guidelines when opening issues or creating pull requests.

changelog

Changelog

All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.

Note that the changelog only dates back to release of v2.0.0.

[2.1.3] (2022-06-07)

Bug Fix

  • Removed source maps from the npm package, since they were causing some issues.

2.1.1 (2021-10-09)

New Feature

  • Exposed the lifetime parameter on the sparkles template, so you can now control the total range of the stars via lifetime and speed (#72).

2.1.0 (2021-09-26)

A lot of quality-of-life changes regarding the library and the respective documentation.

New Feature

  • Added support for the respect-reduced-motion media query. The library now doesn't activate its effects if said query is detected. This can be disabled via a flag in the settings (#74).
  • Added deployment workflows.
  • Added "live codeblocks" to the docs, so you can play around with live examples.

Bug Fix

  • Fixed a bug where the container wouldn't stretch to cover the entire DOM, so particles should no longer be cut off somewhere (#70, #71).
  • Updated some development packages to fix potential security issues.

Polish

  • Revamped the style of the documentation site [party.js.org].
  • Improved the generation of the docs and API (#42).
  • Improved module exporting.

Removed

  • Removed stale-bot from the repository.

2.0.1 (2021-05-17)

Bug Fix

  • Fixed a bug where the dynamic source sampler would confuse Rects and HTMLElements (#60).

2.0.0 (2021-04-18)

The huge rewrite of the entire library. The codebase is now properly structured, typed, tested and documented.