Particles.js: Responsiveness

Created on 17 Mar 2015  路  7Comments  路  Source: VincentGarreau/particles.js

It's not responsive. What are the options to make it responsive?

Most helpful comment

Hi @akashnimare , @dabockster :)

To make it responsive, juste set the "density_auto" option to "true". And with the "density_area" option, you can set an area relative to the defined number of particles (particles.nb option).

particlesJS('particles-js', {
  particles: {
    nb: 80
  },
  interactivity: {
    events: {
      onresize: {
        enable: true,
        density_auto: true,
        density_area: 400 // nb_particles = particles.nb * (canvas width *  canvas height / 1000) / density_area
      }
    }
  }
});

There is a demo juste here: http://vincentgarreau.com/particles.js/responsive

All 7 comments

Is it the topmost

or is there stuff above it in your body tag?

It is the topmost.

Hi @akashnimare , @dabockster :)

To make it responsive, juste set the "density_auto" option to "true". And with the "density_area" option, you can set an area relative to the defined number of particles (particles.nb option).

particlesJS('particles-js', {
  particles: {
    nb: 80
  },
  interactivity: {
    events: {
      onresize: {
        enable: true,
        density_auto: true,
        density_area: 400 // nb_particles = particles.nb * (canvas width *  canvas height / 1000) / density_area
      }
    }
  }
});

There is a demo juste here: http://vincentgarreau.com/particles.js/responsive

@VincentGarreau Thank you!

Hi Vincent, i love particles.
The code you provide about responsiveness, where i need to put it? I have the json file with all the configuration. Thanks!

I am having a similar issue with responsiveness of the particles as well as the mouse location on window size change. Here are examples of what is occuring.

Before screen size change:
https://media.giphy.com/media/xBpGtoZh7l6PAbmlpi/giphy.gif

After: (mouse location moves, and scale of lines/nodes are different)
https://media.giphy.com/media/khOqDEduaH6GsTFBYq/giphy.gif

I am having a similar issue with responsiveness of the particles as well as the mouse location on window size change. Here are examples of what is occuring.

Before screen size change:
https://media.giphy.com/media/xBpGtoZh7l6PAbmlpi/giphy.gif

After: (mouse location moves, and scale of lines/nodes are different)
https://media.giphy.com/media/khOqDEduaH6GsTFBYq/giphy.gif

Can you post your json and your css.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

XRyu picture XRyu  路  6Comments

emilwibe picture emilwibe  路  4Comments

qnoox picture qnoox  路  6Comments

ghost picture ghost  路  7Comments

tbryan2 picture tbryan2  路  5Comments