2.2.3 • Published 6 years ago

particlesjs v2.2.3

Weekly downloads
727
License
MIT
Repository
github
Last release
6 years ago

particles.js

Github file size Travis David David npm CDNJS GitHub license

particles.js is a lightweight, dependency-free and responsive javascript plugin for particle backgrounds.

Installation

There are several ways to install particles.js:

  • Download the latest version
  • Install with npm: npm install particlesjs --save
  • Use the CDN: https://cdnjs.cloudflare.com/ajax/libs/particlesjs/2.2.3/particles.min.js

Usage

Include the minified JS in your HTML (right before the closing body tag).

<body>
  …
  <script src="path/to/particles.min.js"></script>
</body>

Add a canvas element to your markup (it should be the last element)

<body>
  …
  <canvas class="background"></canvas>
  <script src="path/to/particles.min.js"></script>
</body>

Add a few styles to your css.

html,
body {
  margin: 0;
  padding: 0;
}

.background {
  position: absolute;
  display: block;
  top: 0;
  left: 0;
  z-index: 0;
}

Initialize the plugin on the window.onload event.

window.onload = function() {
  Particles.init({
    selector: '.background'
  });
};

Options

OptionTypeDefaultDescription
selectorstring-Required: The CSS selector of your canvas element
maxParticlesinteger100Optional: Maximum amount of particles
sizeVariationsinteger3Optional: Amount of size variations
speedinteger0.5Optional: Movement speed of the particles
colorstring or string[]#000000Optional: Color(s) of the particles and connecting lines
minDistanceinteger120Optional: Distance in px for connecting lines
connectParticlesbooleanfalseOptional: true/false if connecting lines should be drawn or not
responsivearraynullOptional: Array of objects containing breakpoints and options

Example how to use the responsive option.

Methods

MethodDescription
pauseAnimationPauses/stops the particle animation
resumeAnimationContinues the particle animation
destroyDestroys the plugin

Example how to use the public methods.

Browser Support

IE9+ and all modern browsers.

Examples

See various examples how you can use particles.js.

Build

To compile the distribution files by yourself, make sure that you have node.js and gulp installed, then:

  • Clone the repository: https://github.com/marcbruederlin/particles.js.git
  • Change in the project directory: cd particles.js
  • Install the dependencies: npm install
  • Run the gulp build task gulp build to regenerate the dist folder. You can also run gulp build --watch to watch for file changes and automatically rebuild the files.

Using particles.js?

If you’re using particles.js in some interesting way or on a cool site, I’d be very grateful if you shoot me a link to it. For any problems or questions don't hesitate to open an issue.

License

particles.js is created by Marc Brüderlin and released under the MIT license.

Version 1.x

The source code for particles.js 1.x has been moved to the v1 branch.

2.2.3

6 years ago

2.2.2

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.3

7 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago