wufe / react-particles-js

Particles.js for React
https://rpj.bembi.dev/
MIT License
1.16k stars 106 forks source link

Limit maximum amount of onclick particles or un-minify js? #89

Closed bardomudo closed 4 years ago

bardomudo commented 5 years ago

I have my parameters set to create 3 new particles onClick, however I'd like to limit that so my users can't create more than a set number and thus avoid unnnecessary CPU usage and crashes in those scenarios.

In the original implementation of particles-js, I did that by simply adding an if(pJS.particles.array.length<=200) right before the loop that pushes new particles in the pJS events (line 755 of original particles.js).

However, it appears the particles.js from react-particles-js is minifying and I can't do that easily. Would it be possible to add one parameter to limiting the maximum number of new added particles on onClick or providing a regular non minified version of the JS?

matteobruni commented 4 years ago

@bardomudo in the 3.0.1 version there's a limit option

   "number": {
      "density": {
        "enable": false,
        "area": 800
      },
      "limit": 0,
      "value": 100
    },