Giter Club home page Giter Club logo

tsparticles / tsparticles Goto Github PK

View Code? Open in Web Editor NEW
7.0K 117.0 783.0 366.09 MB

tsParticles - Easily create highly customizable JavaScript particles effects, confetti explosions and fireworks animations and use them as animated backgrounds for your website. Ready to use components available for React.js, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Inferno, Solid, Riot and Web Components.

Home Page: https://particles.js.org

License: MIT License

TypeScript 92.98% JavaScript 7.02%
particles typescript npm javascript animations web tsparticles angular svelte confetti

tsparticles's Introduction

banner

tsParticles - TypeScript Particles

A lightweight TypeScript library for creating particles. Dependency free (*), browser ready and compatible with React.js, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Inferno, Riot.js, Solid.js, and Web Components

GitHub Sponsors jsDelivr hits (npm) Cdnjs npm npm lerna CodeFactor Codacy Badge Rate this package Gitpod Ready-to-Code Run on Repl.it

Discord Slack WhatsApp Telegram Reddit

tsParticles Product Hunt Buy Me A Coffee


Table of Contents


Do you want to use it on your website?

Documentation and Development references here 📖

This library is available on two of the most popular CDNs and it's easy and ready to use, if you were using particles.js it's even easier.

You'll find the instructions below, with all the links you need, and don't be scared by TypeScript, it's just the source language.

The output files are just JavaScript. 🤩

CDNs and npm have all the sources you need in Javascript, a bundle browser ready (tsparticles.engine.min.js), and all files splitted for import syntax.

If you are interested there are some simple instructions just below to guide you to migrate from the old particles.js library.

Library installation

Hosting / CDN

Please use these hosts or your own to load tsParticles on your projects

jsDelivr

jsDelivr jsDelivr jsDelivr jsDelivr jsDelivr jsDelivr jsDelivr

cdnjs

Cdnjs

unpkg

https://unpkg.com/@tsparticles/confetti/ https://unpkg.com/@tsparticles/engine/ https://unpkg.com/@tsparticles/fireworks/ https://unpkg.com/@tsparticles/basic/ https://unpkg.com/@tsparticles/slim/ https://unpkg.com/tsparticles/ https://unpkg.com/@tsparticles/all/


npm

tsParticles Confetti

npm npmjs

tsParticles Engine

npm npmjs

tsParticles Fireworks

npm npmjs

tsParticles Basic

npm npmjs

tsParticles Slim

npm npmjs

tsParticles

npm npmjs

tsParticles All

npm npmjs

npm install @tsparticles/engine

yarn

yarn add @tsparticles/engine

pnpm

pnpm install @tsparticles/engine

Import and require

const tsParticles = require("@tsparticles/engine");

// or

import { tsParticles } from "@tsparticles/engine";

The imported tsParticles is the same instance you have when including the script in the page using the <script> tag.


Usage

Load tsParticles and configure the particles:

tsParticles demo tsParticles Confetti demo

index.html

<div id="tsparticles"></div>

<script src="tsparticles.engine.min.js"></script>

app.js

// @path-json can be an object or an array, the first will be loaded directly, and the object from the array will be randomly selected
/* tsParticles.load(@params); */

tsParticles
    .load({
        id: "tsparticles",
        url: "presets/default.json",
    })
    .then(container => {
        console.log("callback - tsparticles config loaded");
    })
    .catch(error => {
        console.error(error);
    });

//or

tsParticles.load({
    id: "tsparticles",
    options: {
        /* options here */
    },
});

//or

tsParticles.load({
    id: "tsparticles",
    options: [
        {
            /* options here */
        },
        {
            /* other options here */
        },
    ],
});
//random object

tsParticles.load({
    id: "tsparticles",
    options: [
        {
            /* options here */
        },
        {
            /* other options here */
        },
    ],
    index: 1,
}); //the second one
// Important! If the index is not in range 0...<array.length, the index will be ignored.

// after initialization this can be used.

/* tsParticles.setOnClickHandler(@callback); */

/* this will be fired from all particles loaded */

tsParticles.setOnClickHandler((event, particles) => {
    /* custom on click handler */
});

// now you can control the animations too, it's possible to pause and resume the animations
// these methods don't change the config so you're safe with all your configurations
// domItem(0) returns the first tsParticles instance loaded in the dom
const particles = tsParticles.domItem(0);

// play will start the animations, if the move is not enabled it won't enable it, it just updates the frame
particles.play();

// pause will stop the animations
particles.pause();

Official components for some of the most used frameworks

Angular

@tsparticles/angular

npm npm

Instructions available here

Astro

astro-particles

npm npm

Instructions available here

Ember.js

ember-tsparticles

npm npm

Instructions available here

Inferno

inferno-particles

npm npm

Instructions available here

jQuery

jquery-particles

npm npm

Instructions available here

Preact

preact-particles

npm npm

Instructions available here

ReactJS

@tsparticles/react

npm npm

Instructions available here

RiotJS

riot-particles

npm npm

You can find the instructions here

SolidJS

solid-particles

npm npm

You can find the instructions here

Svelte

@tsparticles/svelte

npm npm downloads

Instructions available here

VueJS 2.x

@tsparticles/vue2

npm npm

Instructions available here

VueJS 3.x

@tsparticles/vue3

npm npm

Instruction available here

Web Components

web-particles

npm npm

You can find the instructions here

WordPress

@tsparticles/wordpress

npm npm WordPress Plugin Downloads WordPress Plugin Active Installs

The plugin page hosted on WordPress.org can be found here

Elementor

Actually, an official tsParticles plugin isn't existing, but I have a collaboration with the Premium Addons for Elementor plugin collection.

Premium Addons for Elementor
Premium Addons for Elementor is one of the most common plugins for Elementor that offers more than 55 highly customizable Elementor Widgets and Section Add-ons. tsParticles is exclusively included in Premium Particles Section Add-on for Elementor Page Builder. Check It Now.
Use Premium Addons for Elementor Page Builder and get the chance to include tsParticles in your next WordPress website without the need to write a single line of code. See a Live Example.

Presets

There are some presets ready to be used in this repository, and they also have a bundle file that contains everything needed to run.

Big Circles

jsDelivr npmjs npmjs

This preset loads big colored circles moving upwards on a white background.

demo

You can find the instructions here

Bubbles

jsDelivr npmjs npmjs

This preset loads colored bubbles coming from the bottom of the screen on a white background.

demo

You can find the instructions here

Confetti

jsDelivr npmjs npmjs

This preset loads white and red confetti launched from the screen center on a transparent background.

demo

You can find the instructions here

Fire

jsDelivr npmjs npmjs

This preset loads a faded red to a black background with particles colored like fire and ash sparks.

demo

You can find the instructions here

Firefly

jsDelivr npmjs npmjs

This preset loads a mouse trail made with small fading particles like little fireflies.

demo

You can find the instructions here

Fireworks

jsDelivr npmjs npmjs

This preset loads a beautiful fireworks effect.

demo

You can find the instructions here

Fountain

jsDelivr npmjs npmjs

demo

You can find the instructions here

Links

jsDelivr npmjs npmjs

demo

You can find the instructions here

Sea Anemone

jsDelivr npmjs npmjs

demo

You can find the instructions here

Snow

jsDelivr npmjs npmjs

demo

You can find the instructions here

Stars

jsDelivr npmjs npmjs

demo

You can find the instructions here

Triangles

jsDelivr npmjs npmjs

demo

You can find the instructions here


Templates and Resources

You can find some tsParticles related templates here. The templates are created for Vanilla Javascript, ReactJS, VueJS, Angular, SvelteJS, and other frameworks.

The templates will vary, new ones can be created or older ones updated with the latest features or changed to a better style. Check them out once in a while.

If you created some good design with tsParticles feel free to submit a pull request with your cool template, you'll be credited as the template author!

https://github.com/tsparticles/templates


Demo / Generator

https://particles.js.org/samples

Particles demo


Video Tutorials

You can find all video tutorials on the website here: https://particles.js.org/video.html

More videos are coming soon! Check every day if there are some new contents.


Characters as particles

Particles chars demo


Polygon mask

tsParticles Polygon Mask demo


Animated stars

Particles NASA demo


Nyan cat flying on scrolling stars

Particles Nyan Cat demo


Snow particles

tsParticles Snow demo


Background Mask particles

tsParticles Background Mask demo


particles.json

You can find some config samples here 📖


Options

You can find all options available here 📖

Want to see it in action and try it?

I've created a tsParticles collection on CodePen 😮 or you can check out my profile

Otherwise, there's the demo page link below.

tsParticles demo

Want to see even more demos? Clone the repository on your computer and follow these instructions

$ pnpm i
$ pnpm run build
$ cd demo/vanilla
$ pnpm start

Boom! 💥 http://localhost:3000 and you can check out other demos.

If you are brave enough you can switch to the dev branch for trying the features under development.


Migrating from Particles.js

tsParticles has a package that makes this library 100% compatible with the particles.js configuration.

jsDelivr npmjs npm

Seriously, you just need to change the script from particles.js to the bundled compatibility package, et-voilà, you're ready 🧙!

You can read more here

Want to know 5 reasons to do the switch? Read here

Below you can find all the information you need to install tsParticles and its new syntax.


Plugins/Customizations

tsParticles now supports some customizations 🥳.

You can create your own plugins

Read more here...


Dependency Graph

flowchart TD

  subgraph core [Core]
    engine[tsParticles Engine]
    perlin-noise[Perlin Noise Lib]
    simplex-noise[Simplex Noise Lib]
    configs[tsParticles Configs]
  end

  subgraph bundle-basic [tsParticles Basic]

    subgraph basic-movers [Movers]
      move-base[Base]
    end

    subgraph basic-shapes [Shapes]
      shape-circle[Circle]
    end

    subgraph basic-updates [Updaters]
      updater-color[Color]
      updater-opacity[Opacity]
      updater-out-modes[Out Modes]
      updater-size[Size]
    end

  end

  engine --> bundle-basic

  subgraph bundle-confetti [tsParticles Confetti]

    subgraph confetti-plugins [Plugins]
      plugin-emitters
      plugin-motion
    end

    subgraph confetti-shapes [Shapes]
      shape-cards
      shape-emoji
      shape-heart
      shape-image
      shape-polygon
      shape-square
      shape-star
    end

    subgraph confetti-updaters [Updaters]
      updater-life
      updater-roll
      updater-rotate
      updater-tilt
      updater-wobble
    end

  end

  bundle-basic --> bundle-confetti

  subgraph bundle-slim [tsParticles Slim]

    subgraph slim-interactions [Interactions]

      subgraph slim-interactions-external [Externals]
        interaction-external-attract[Attract]
        interaction-external-bounce[Bounce]
        interaction-external-bubble[Bubble]
        interaction-external-connect[Connect]
        interaction-external-grab[Grab]
        interaction-external-pause[Pause]
        interaction-external-push[Push]
        interaction-external-remove[Remove]
        interaction-external-repulse[Repulse]
        interaction-external-slow[Slow]
      end

      subgraph slim-interactions-particles [Particles]
        interaction-particles-attract[Attract]
        interaction-particles-collisions[Collisions]
        interaction-particles-links[Links]
      end

    end

    subgraph slim-movers [Movers]
      move-parallax[Parallax]
    end

    subgraph slim-plugins [Plugins]

      subgraph slim-plugins-easings [Easings]
        plugin-easing-quad[Quad]
      end

    end

    subgraph slim-shapes [Shapes]
      shape-emoji[Emoji]
      shape-image[Image]
      shape-line[Line]
      shape-polygon[Polygon]
      shape-square[Square]
      shape-star[Star]
    end

    subgraph slim-updaters [Updaters]
      updater-life[Life]
      updater-rotate[Rotate]
      updater-stroke-color[Stroke Color]
    end

  end

  bundle-basic --> bundle-slim

  subgraph bundle-fireworks [tsParticles Fireworks]

    subgraph fireworks-effects [Effects]
      effect-trail
    end

    subgraph fireworks-plugins [Plugins]
      plugin-emitters

      subgraph fireworks-plugin-emitters-shapes [Emitters Shapes]
        plugin-emitters-shape-square
      end

      plugin-sounds
    end

    subgraph fireworks-updaters [Updaters]
      updater-destroy
      updater-life
      updater-rotate
    end

  end

  bundle-basic --> bundle-fireworks

  subgraph bundle-full [tsParticles]

    subgraph full-interactions [Interactions]

      subgraph full-interactions-external [Externals]
        interaction-external-trail[Trail]
      end

    end

    subgraph full-plugins [Plugins]
      plugin-absorbers[Absorbers]
      plugin-emitters[Emitters]

      subgraph full-plugin-emitters-shapes [Emitters Shapes]
        plugin-emitters-shape-circle[Circle]
        plugin-emitters-shape-square[Square]
      end

    end

    subgraph full-shapes [Shapes]
      shape-text[Text]
    end

    subgraph full-updaters [Updaters]
      updater-destroy[Destroy]
      updater-roll[Roll]
      updater-tilt[Tilt]
      updater-twinkle[Twinkle]
      updater-wobble[Wobble]
    end

  end

  bundle-slim --> bundle-full

  subgraph bundle-all [tsParticles All]

    bundle-pjs[tsParticles Particles.js Compatibility]

    subgraph all-effects [Effects]
      effect-bubble[Bubble]
      effect-trail[Trail]
    end

    subgraph all-interactions [Interactions]
      subgraph all-interactions-external [External]
        interaction-external-particle[Particle]
        interaction-external-pop[Pop]
      end

      interaction-light[Light]

      subgraph all-interactions-particles [Particles]
        interaction-particles-repulse[Repulse]
      end
    end

    subgraph all-paths [Paths]
      path-curl-noise[Curl Noise]
      path-curves[Curves]
      path-perlin-noise[Perlin Noise]
      path-polygon[Polygon]
      path-simplex-noise[Simplex Noise]
      path-svg[SVG]
    end

    subgraph all-plugins [Plugins]
      plugin-canvas-mask[Canvas Mask]

      subgraph all-plugins-easings [Easings]
        plugin-easing-back[Back]
        plugin-easing-circ[Circ]
        plugin-easing-cubic[Cubic]
        plugin-easing-expo[Expo]
        plugin-easing-linear[Linear]
        plugin-easing-quart[Quart]
        plugin-easing-quint[Quint]
        plugin-easing-sine[Sine]
      end

      subgraph all-plugin-emitters-shapes [Emitters Shapes]
        plugin-emitters-shape-canvas[Canvas]
        plugin-emitters-shape-path[Path]
        plugin-emitters-shape-polygon[Polygon]
      end

      subgraph all-plugins-exports [Exports]
        plugin-export-image[Image]
        plugin-export-json[JSON]
        plugin-export-video[Video]
      end

      plugin-hsv-color[HSV Color]
      plugin-infection[Infection]
      plugin-motion[Motion]
      plugin-poisson-disc[Poisson Disc]
      plugin-polygon-mask[Polygon Mask]
      plugin-sounds[Sounds]
    end

    subgraph all-shapes [Shapes]
      shape-arrow[Arrow]
      shape-cards[Cards]
      shape-cog[Cog]
      shape-heart[Heart]
      shape-path[Path]
      shape-rounded-polygon[Rounded Polygon]
      shape-rounded-rect[Rounded Rect]
      shape-spiral[Spiral]
    end

    subgraph all-updaters [Updaters]
      updater-gradient[Gradient]
      updater-orbit[Orbit]
    end

    simplex-noise --> path-curl-noise
    perlin-noise --> path-perlin-noise
    simplex-noise --> path-simplex-noise

  end

  bundle-full --> bundle-all

JetBrains JetBrains

Sponsors

JetBrains

Huge thanks to JetBrains for the 2020-2022 Open Source Licenses!

JetBrains WebStorm is used to maintain this project.

tsparticles's People

Contributors

alphabyte-redteam avatar code-factor avatar dependabot-preview[bot] avatar dependabot[bot] avatar dipree avatar enhmunh-e avatar gabrielbarker avatar gaurang7goel avatar goldenmaximo avatar guzzler avatar himanshunitrr avatar imgbotapp avatar jzjzjzj avatar lianplass avatar manusquall avatar matteobruni avatar matteoums avatar pborreli avatar piecemaker avatar progers avatar renovate-bot avatar renovate[bot] avatar roslaneshellanoo avatar sidibecker avatar snyk-bot avatar timscodebase avatar tylerburnett avatar victorbstan avatar vincentgarreau avatar wufe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tsparticles's Issues

Collision System

The particles should have a collision system, controlled by an option.

The collision can have various modes:

  • Merge: The particles colliding should create a larger one
  • Bounce: The particles colliding will bounce away
  • Destroy: The particles colliding will destroy

Merge Mode: The larger one should be the one remaining and the one that become larger

Destroy Mode: The smaller particles could destroy against a larger one which remain intact or could become smaller. Two same size particles should destroy themself

Orbits around particles

I think that some orbit options to make them appear around particles should be cool to see, maybe more than 1 orbit, with different radius and angle (0 to Math.PI to detect the distortion, at Math.PI / 2 it should be a straight line cutting the particle in half and the satellite, if present, should go only up and down, at 0 and Math.PI the orbit is circular)

Documentation

Now when the project builds creates a docs folder with typedoc.
All classes, interfaces and methods should be commented to populate the docs so contributing should be easier.

Particles Shadow

I started working on a shadow implementation, but when I tested it the performance was really poor because of the shadow, not only the shadowBlur.
If someone has an idea to improve that it's really welcome.
I'll do more research about, but the issue is open to be shared.

Parallax

The parallax was in development when I forked the source repo, in fact it has some issues keeping the particles aligned.

Slow down on hover

Add effect of slowing down in a configurable radius around the mouse pointer

More customizable strokes

Thanks to @calebfergie I've just seen the random stroke option, it's an interesting option. Every stroke should implement it and the random will be a boolean and not a "random" string value.

Responsive Particles limit

Thanks to @meirroth on SO I found this

/* ---------- pJS functions - modes events ------------ */

pJS.fn.modes.pushParticles = function(nb, pos){

  pJS.tmp.pushing = true;

  var limitNumOfParticles = Math.floor(pJS.canvas.el.width / 20);

  if(pJS.particles.array.length < limitNumOfParticles){

    // console.log("limit: ", limitNumOfParticles);
    // console.log("array: ", pJS.particles.array.length);

    for(var i = 0; i < nb; i++){
      pJS.particles.array.push(
        new pJS.fn.particle(
          pJS.particles.color,
          pJS.particles.opacity.value,
          {
            'x': pos ? pos.pos_x : Math.random() * pJS.canvas.w,
            'y': pos ? pos.pos_y : Math.random() * pJS.canvas.h
          }
        )
      )
      if(i == nb-1){
        if(!pJS.particles.move.enable){
          pJS.fn.particlesDraw();
        }
        pJS.tmp.pushing = false;
      }
    }
  }
};

This feature seems interesting in limiting the particles based on the canvas size but It will be managed by an option.

Improve library output files

The library uses babel + webpack to build its output files but they'll be condensed in a single big file.
The output file is currently including pathseg library too and I think this is not a best practice.

If I want to add a webGL library in the future this will be a big issue so this need to be improved.

Initialize particles after destroy

Referencing issue VincentGarreau/particles.js#405

I am aware of the way of destroying particles as described in #63
After destroying, it is not possible anymore to initialize and start particles because of the error TypeError: Cannot read property 'push' of null

Codesandbox example: https://codesandbox.io/s/quirky-black-yc3fg

How to reproduce:

1. click on start button to start the particles (everything is okay)

2. click on destroy button to destroy the particles (everything is okay)

3. click on start button to start the particles again (not working)

@dekadentno can you try your issue with this library? Does the bug still exist?

Particles become distorted. Various CODE.

Issue VincentGarreau/particles.js#433 from the original project

Good morning! Previously I would like to thank everyone!

My site: http://www.wizardingescaperooms.com/

I am going crazy looking for a solution. If I add the particles to the section, in the long run, they become distorted.

I have added the following code, and they look perfectly, but they do not cover the total of the page, I have touched several values, but it always lengthens and blurs the particles.

PARTICLE CODE

particlesJS('fondo_particulas1', { "particles": { "number": { "value": 600, "density": { "enable": true, "value_area": 800 } }, "color": { "value": "#ffffff" }, "shape": { "type": "circle", "stroke": { "width": 0, "color": "#000000" }, "polygon": { "nb_sides": 8 }, "image": { "src": "img/github.svg", "width": 100, "height": 100 } }, "opacity": { "value": 1, "random": false, "anim": { "enable": true, "speed": 2.7610625218245732, "opacity_min": 0, "sync": false } }, "size": { "value": 1, "random": true, "anim": { "enable": true, "speed": 0, "size_min": 97.44926547616141, "sync": true } }, "line_linked": { "enable": false, "distance": 0, "color": "#ffffff", "opacity": 0.4, "width": 1 }, "move": { "enable": true, "speed": 0, "direction": "none", "random": true, "straight": false, "out_mode": "bounce", "bounce": false, "attract": { "enable": false, "rotateX": 100, "rotateY": 100 } } }, "interactivity": { "detect_on": "canvas", "events": { "onhover": { "enable": false, "mode": "bubble" }, "onclick": { "enable": false, "mode": "repulse" }, "resize": true }, "modes": { "grab": { "distance": 97.44926547616143, "line_linked": { "opacity": 0.7239044775137166 } }, "bubble": { "distance": 250, "size": 0, "duration": 2, "opacity": 0, "speed": 3 }, "repulse": { "distance": 400, "duration": 0.4 }, "push": { "particles_nb": 4 }, "remove": { "particles_nb": 2 } } }, "retina_detect": true } );

ADDITIONAL CSS CODE

/*Fondo estrellado alto total sin pixelar*/.particles-js-canvas-el { height: 100vmax !important; z-index: 0; }
Do you know any solution?
Thank you!

This issue was reported in the original project by @EdgarGR

This is the config beautified

{
  "particles": {
    "number": {
      "value": 600,
      "density": {
        "enable": true,
        "value_area": 800
      }
    },
    "color": {
      "value": "#ffffff"
    },
    "shape": {
      "type": "circle",
      "stroke": {
        "width": 0,
        "color": "#000000"
      },
      "polygon": {
        "nb_sides": 8
      },
      "image": {
        "src": "img/github.svg",
        "width": 100,
        "height": 100
      }
    },
    "opacity": {
      "value": 1,
      "random": false,
      "anim": {
        "enable": true,
        "speed": 2.7610625218245732,
        "opacity_min": 0,
        "sync": false
      }
    },
    "size": {
      "value": 1,
      "random": true,
      "anim": {
        "enable": true,
        "speed": 0,
        "size_min": 97.44926547616141,
        "sync": true
      }
    },
    "line_linked": {
      "enable": false,
      "distance": 0,
      "color": "#ffffff",
      "opacity": 0.4,
      "width": 1
    },
    "move": {
      "enable": true,
      "speed": 0,
      "direction": "none",
      "random": true,
      "straight": false,
      "out_mode": "bounce",
      "bounce": false,
      "attract": {
        "enable": false,
        "rotateX": 100,
        "rotateY": 100
      }
    }
  },
  "interactivity": {
    "detect_on": "canvas",
    "events": {
      "onhover": {
        "enable": false,
        "mode": "bubble"
      },
      "onclick": {
        "enable": false,
        "mode": "repulse"
      },
      "resize": true
    },
    "modes": {
      "grab": {
        "distance": 97.44926547616143,
        "line_linked": {
          "opacity": 0.7239044775137166
        }
      },
      "bubble": {
        "distance": 250,
        "size": 0,
        "duration": 2,
        "opacity": 0,
        "speed": 3
      },
      "repulse": {
        "distance": 400,
        "duration": 0.4
      },
      "push": {
        "particles_nb": 4
      },
      "remove": {
        "particles_nb": 2
      }
    }
  },
  "retina_detect": true
}

The original project is abandoned and you won't find any help, try with this project and if it's affected by the same bug we can find a solution

Simple presets

Configs are always painful, a lot of options and often we don't know what they'll change.
A set of presets should implemented and adding them to the config should be clearer and our config can be slimmer and concentrate more on particles number or just a bunch of settings we can change.

{
    particles: { number: { value: 100 } },
    preset: 'snow'
}

or

{
    particles: { number: { value: 100 } },
    preset: ['basic', 'bouncing']
}

and we're set.

This will be a great feature for who wants to use the library

SVG not working

The demo in the dev branch is now fixed with an existing svg image but it doesn't show the svg.

Touch-Drag mobile pushes particles

With mobile devices if you move with your finger around at the release particles will be pushed if push is enabled on click.
This behavior must be fixed, if you’re moving you don’t want pushes

demo set up

Hi Vincent, just one simple question, I need to set up demo version with particle.json. The demo version works like a charm on my localhost, so I modified the js/app.js and uncommented the

particlesJS.load('particles-js', 'particles.json', function() {
console.log('particles.js loaded - callback');
});
and commented the "/* Otherwise just put the config content (json):

particlesJS('particles-js',

{..."
the demo index doesn't give me any particles. I guess this is just a matter of urls for particles-js and particles.json but can't find the right path.

The files are out of the box.
Thanks.

Original project issue VincentGarreau/particles.js#425 thanks to @fabvincent


The original project is abandoned, if need help to configure a particles instance you can ask me, your config still works with this project

Particle grouping

Referencing VincentGarreau/particles.js#415 from the original project.

I in need of Is there a way to create multiple particle configurations and let the library choose randomly based on a proportion between them?

I need to animate two separate groups of particles, each with different velocities and appearances. I may be able to implement that, but I have no idea how the config file should look like 😅

@ioxua You need more one Particles instance randomly chosen from an array, or a similar object, to render in a single object, right?

On hover bubble works as hole to show underlying background

Hello I have tried and tried to work out if this is possible using particle.js

I want an image as a background and a white layer over this that when you hover over the particle layer the bubbles show image underneath a bit like this.

https://revolution.themepunch.com/particle-effect-for-wordpress/

any help would help me keep little hair I have left lol

Kind regards

Mike

Original project issue VincentGarreau/particles.js#428 thanks to @Mickperks


The original project is abandoned, I'll have a look on it, it seems really cool

Howe to change shapes/images

Issue from the original project VincentGarreau/particles.js#413

Trying to figure out how to add different shapes than the few that's already in the drop down. Looking for like hearts, and other basic shapes. Changing images also isn't working. I can only pick pre-installed shapes.

by @tommytekkno

This feature seems interesting, do you have some shape recommendations? This library has more shapes than the original project. If you are missing something feel free to ask it

Particles speed

The particles speed sometimes can be faster than the original project. The issue is related to the introduction of fps_limit and delta.
The delta is the difference between the last timestamp of animation and the current timestamp so it depends on fps_limit and its framerate blocks. The idea it's fine but comparing the original project they're faster and can be messy with the old configs.

tsParticles Default values

The default values are ugly as hell. Some nicer are needed to init library with a good default effect.
Less options enabled is the best solution, so they don't create conflicts.

To change the default values only the classes under Options folder needs changes.

Touches on mobile

Touches on mobile has some precision issues, the finger is not always well followed

Image particles on hover doesn't change opacity.

Referencing issue VincentGarreau/particles.js#393 from source project

Hey guys,

Changing opacity of the default particles onhover definitely works.
But when I try to change the opacity of the imported svg image, the opacity doesn't seem to change.

Here's my option

particles: {
      number: {
        value: 5,
        density: {
          enable: true,
          value_area: 200,
        },
      },
      line_linked: {
        enable: false,
      },
      color: {
        value: '#2f3236',
      },
      move: {
        enable: true,
        random: true,
        speed: 2,
        bounce: false,
        direction: 'top',
        out_mode: 'out',
        attract: {
          enable: true,
          rotateX: 100,
        },
      },
      size: {
        value: 10,
        random: false,
        anim: {
          enable: true,
          speed: 1,
          size_min: 8,
        },
      },
      opacity: {
        value: 0,
        random: false,
        anim: {
          enable: false,
        },
      },
      shape: {
        type: ['images'],
        polygon: {
          nb_sides: 4,
        },
        images: [
          { src: importedSVG, height: 24, width: 24 },
        ],
      },
    },
    interactivity: {
      detect_on: 'canvas',
      events: {
        onhover: {
          enable: true,
          mode: 'bubble',
        },
        onclick: {
          enable: true,
          mode: 'push',
        },
      },
      modes: {
        push: {
          particles_nb: 4,
        },
        bubble: {
          distance: 300,
          size: 10,
          duration: 2,
          opacity: 1,
          speed: 3,
        },
      },
    },
    retina_detect: true,

@chris542 Can you try it here? Is it still buggy?

How to change particle options on the fly?

Hi, thank you for this, I've just tried switching to this from the original version and I can say so far so good.

However I can't seem to find a way to change the config options on the fly. In the original I can do like this:

const pJS = global.pJSDom[0].pJS;

pJS.particles.color.value = currentTheme.color;
pJS.particles.line_linked.color = currentTheme.color;
pJS.particles.shape.stroke.color = currentTheme.bgColor;
pJS.fn.particlesRefresh();

How can I achieve the same thing with this?

Click events freezes animation

In Snow demo you can reproduce the bug, if you click in the canvas the animations stops and restarts after the event. In the original repository this is not happening.

Customizable background

tsParticles should have a background section in config to set canvas background settings.

This will be an awesome feature to have with presets (custom and standard).

Utilization of tsParticles with a React App [Help?]

The Problem
How does (a novice react developer) use this library with a TypeScript react app? (Created with create-react-app's typescript version)

Solution
Steps to reproduce the behavior:

  1. Install yarn add tsparticles
  2. Add import tsParticles from 'tsparticles'; to the top of the file that you want to have tsParticles (tsParticles should not have type any)
  3. Call tsParticles from react component body to attach it to a jsx-rendered div component

Some documentation for use web apps would be greatly appreciated!

Additional context
My development environment is NextJS/React/TypeScript, would greatly appreciate using this to add an extra "glow" to the UI. NextJS isn't a single-page web app, so globally importing the JS as mentioned in the UI is expensive for an effect in use on only a few pages.

Another dependency I used had a similar TypeScript-lacking-types issue. That plugin, however, also featured documentation for using with React.

Additional context
Add any other context or screenshots about the feature request here.

Customizable Shapes

tsParticles should have an entry point for plugin shapes, something fully customizable.

A developer could want a new shape that is not included here, he should be able to create it's own shape and make it work in no time.

Unify color management

The color properties in the options are not aligned, they should instead use the same properties and values possibilities.

Thanks to @calebfergie it's interesting to have a more customizable opacity. This could be integrated in the color options instead of being separated.

The random color/opacity options should be a boolean option and not a "random" string. LineLinked have a valid "mid" value that creates a gradient from p1 to p2 based on radius difference, this should be a boolean instead of a string "mid"

Customizable presets

The new preset feature should be more customizable giving the opportunity to everyone to create custom presets ready to use that can be easily shared.

Migration to WebGL

A migration to WebGL instead of the canvas 2d context will be a great performance improvement.
This migration will require a lot of rework, so it will be implemented in a not so near future, hope as soon as possible as always.
If someone wants to contribute is really welcome

How to change canvas width and height when we use particles.js?

Referencing issue VincentGarreau/particles.js#391

@N-Asadnajafi

As I surfed the internet and couldn't find a clear solution, I decided to share the solution that I finally discovered :D
Here is my solution:

1. import particles.js to your html file

2. open particles.js and search for the word 'canvas' , you'll find this line of code :
   "var canvas_el = document.createElement('canvas');"

3. look at the next lines, you can simply modify the width and height.
   As an example:
   canvas_el.style.width = "1920" + "px";
   canvas_el.style.height = "1080" + "px";

I'd be appreciate any other solutions

@reginpv

Hi @N-Asadnajafi ,

My solution is to use the callback function like so:

particlesJS.load('particles-js', '/vendors/particles.js-master/particles.json', function() {
      console.log('callback - particles.js config loaded');
      let el = document.querySelector(".particles-js-canvas-el"); 
      el.setAttribute("height", "300px");
});

Let me know how it worked for you.

I'll add a customizable container size option as soon as possible, can you check if your workarounds works here too?

mouse event not working

Something in the project reorganize has broken the mouse events. The only version affected is the 1.5.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.