Tsparticles: Particles get squished together when the window is shrunk but stay squished together when window is expanded

Created on 29 Sep 2020  路  2Comments  路  Source: matteobruni/tsparticles

Is your feature request related to a problem? Please describe.
I am using a config based heavily on the preset named Presets. Open that link and try this for yourself: When I resize my browser to be smaller, the particles gets all squished together and then when I make my browser window bigger, they stay squished together. I do not want this behavior.

Describe the solution you'd like
How do I reset the particles when the window gets resized? Or make the particles spread out more when the browser gets bigger?

Core Hacktoberfest enhancement good first issue help wanted up-for-grabs

All 2 comments

Issue-Label Bot is automatically applying the label feature_request to this issue, with a confidence of 0.61. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

Hi @baieric,

This behavior can be hard to resolve because reposition particles after a window resize can bring unexpected side effects.
If you want particles to be always well fit inside the window you can try to refresh the particles like this:

window.addEventListener("resize", function () { // or () => { if you prefer lambdas
    var container = tsParticles.domItem(0); // or let or const

    if (!container) {
        return;
    }

    container.refresh();
});

This will reload the options restarting all the animations. It's a workaround to have particles always well fit, but if you have emitters or absorbers this solution won't fit very well since they'll be reset too.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

microraptor picture microraptor  路  3Comments

darekaze picture darekaze  路  3Comments

matteobruni picture matteobruni  路  6Comments

paul300497 picture paul300497  路  5Comments

matteobruni picture matteobruni  路  4Comments