particles.js icon indicating copy to clipboard operation
particles.js copied to clipboard

Add ability for user to load a config as JS object OR file path

Open tjhillard opened this issue 9 years ago • 8 comments
trafficstars

Re-opening #139 with dev base.


In the current state of particles.js, a user can only supply a config via loading a file path to a .json file. This works fine in some scenarios, but for example in my case, where I am updating config variables on the go based on user selected variables, I needed a way to pass my dynamic config without having to write to, update and parse a .json file over an over again which is slow and taxing.

This simple PR, which only adds a few lines of code on the load method simply checks if the config being passed is an Object or file path then handles appropriately. All existing functionality remains.

Note: All extra deletions in this commit simply remove empty spaces.

tjhillard avatar Jul 28 '16 13:07 tjhillard

Can we support this?

montogeek avatar Sep 08 '16 19:09 montogeek

Seems like this library isn't being actively maintained anymore. :( Feel free to just copy my code via the commit.

tjhillard avatar Sep 14 '16 19:09 tjhillard

@tjhillard I did, but can not install it. Webpack says that can not found the module :/ Any idea?

montogeek avatar Sep 14 '16 19:09 montogeek

It must be an integration issue or (less likely) a compatibility issue with webpack and this lib.

tjhillard avatar Sep 14 '16 19:09 tjhillard

I will figure it out, thanks for the code!

montogeek avatar Sep 14 '16 19:09 montogeek

Cheers!

tjhillard avatar Sep 14 '16 19:09 tjhillard

+

dmitryrn avatar Mar 02 '18 10:03 dmitryrn

window.particlesJS(tag_id, params); (For anyone still using this library)

phm07 avatar Jun 28 '21 20:06 phm07