问题
Apologies for my complete lack of javascript intuition, but I was wondering if it is possible to change properties of a particles.js object dynamically:
I'm using jQuery
to detect when a user moves a slider on the screen (successfully). However, I was wondering how to apply these slider-value changes to the particles.js
canvas I have in the background.
I.e. Move the slider across, and the particles get larger.
However, I'm not sure how to update the particles.js
— is anyone familiar with a callback or animation loop function that I can drop my property changes into?
回答1:
There is an open issue on this subject. But you can change it manually by accessing the radius property of each particle:
pJS.particles.array.forEach(function(p) {
p.radius = p.radius * sliderValue; // change by a factor
p.radius = sliderValue; // change to a single size
});
来源:https://stackoverflow.com/questions/28738469/particles-js-modify-on-frame-change