tsparticles / tsparticles

tsParticles - Easily create highly customizable JavaScript particles effects, confetti explosions and fireworks animations and use them as animated backgrounds for your website. Ready to use components available for React.js, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Inferno, Solid, Riot and Web Components.
https://particles.js.org
MIT License
7.18k stars 798 forks source link

[Bug]: #5341

Closed BonnY0 closed 1 month ago

BonnY0 commented 1 month ago

Contact Details

No response

What happened?

There is sort of a memory leak, the number of particles increases and memory usage spikes, when I zoom out in browser or use desktop mode when testing on mobile phone. How do I keep the same number of particles on any screen size.

The first picture shows normal browser zoom at 100% and the second shows zoomed out you can see that the number of particles is a lot more than it is supposed to be. 100%z zoomout

tsParticles Version

3.0.2

tsParticles Configuration

tsParticles.load({ 
  id: "tsparticles", 
  options: { 
    preset: "links",
    background: {
      color: {
        value: "#00000" 
      }
    },
    fullScreen: {
      enable: false 
    },
    particles: {
      number: {
        value: 150,
        density: {
          enable: true,
          value_area: 400 
        }
      },
      links: {
        color: "#0d044f" 
      }
    }
  } 
});

What browsers are you seeing the problem on?

Firefox, Chrome, Microsoft Edge

Relevant log output

No response

Code of Conduct

matteobruni commented 1 month ago

Disable density in particles number options

BonnY0 commented 1 month ago

Yes but now in mobile version the number of particles is a lot in default resolution

matteobruni commented 1 month ago

You asked same number in any screen size, that’s how you achieve it. If you want different numbers between mobile and desktop, use two different options and load them checking the browser name or other parameters

BonnY0 commented 1 month ago

How do I achieve that, is it possible with config parameters or I need another js checking for browser size

matteobruni commented 1 month ago

How do I achieve that, is it possible with config parameters or I need another js checking for browser size

For mobile detection you need custom js code, responsive options are based on screen size

BonnY0 commented 1 month ago

Thanks