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

Where is the object

Open javismiles opened this issue 8 years ago • 5 comments

Im confused. I run your demos and examples all great, no probs. But now I want to dynamically, at runtime, modify some properties. You say I can use the pJS object pJS.particles.color_random = true;

but every time I try to use it I get JS error, undefined,

where is that object, how can I access it, its never declared or used in your demos

thank you

javismiles avatar Sep 24 '16 13:09 javismiles

Yeah, some documentation on how to access particlesJS properties would be magic.

mrsubtle avatar Feb 06 '17 19:02 mrsubtle

pJSDom[0] is the first pJS object that you can access and change its particles properties.

NordlingDev avatar Jun 04 '17 12:06 NordlingDev

Slight adendum to NorlingArt's answer:

The options are accessible within pJSDom[0].pJS

So to change the particles speed: pJSDom[0].pJS.particles.speed = 50; etc.

itsalaidbacklife avatar Apr 03 '18 17:04 itsalaidbacklife

It is literally pJSDom[0], he is not referring to a placeholder, you just write pJSDom[0] in your code, and then pJS and the property you want to change.

Pretty straightforward, but somehow confusing.

PD: remember to pJSDom[0].pJS.fn.particlesRefresh()

rtrevinnoc avatar Jun 18 '18 22:06 rtrevinnoc

I'm facing the same issue, pJSDom is empty and I'm not able to access pJS at 0 position. How can I change the color dynamically?

pJSDom[0].pJS.particles.color.value = '#FF0000'; pJSDom[0].pJS.fn.particlesRefresh();

I get the below following error:

Uncaught TypeError: Cannot read property 'pJS' of undefined at HTMLDocument.<anonymous> (background-script.js?ver=1.2.0:19)

premanshupandey avatar Mar 15 '21 03:03 premanshupandey