wufe / react-particles-js

Particles.js for React
https://rpj.bembi.dev/
MIT License
1.15k stars 106 forks source link

density doesn't work stably on smaller screen sizes #60

Closed WebDeg-Brian closed 5 years ago

WebDeg-Brian commented 5 years ago

Source code:

I probably have done something wrong. Here is the my particles setup:

import React from 'react';

import styled from 'styled-components';

import ParticlesCanvas from 'react-particles-js';

const StyledParticlesWrapper = styled.div`
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
`;

export default Particles = props => {
  return (
    <StyledParticlesWrapper>
      <ParticlesCanvas params={{
        particles: {
          number: {
            value: 80,
            density: {
              enable: true,
              value_area: 800
            }
          }
        }
      }} />    
    </StyledParticlesWrapper>
  );
}

Behaviour

When the page is loaded on a big screen size, density works. When resizing to a small enough screen size, density sometimes works, sometimes doesn't. I tested the app on iPhoneX and Galaxy S9 screen size as well as responsive mode.

Particles when loaded on a big screen size: image

Particles when being resized (Sometimes it works): image

Particles when being resized (Sometimes it doesn't work): image

How should I fix it? Thanks in advance

My project repo: Eagle Nest The particles file: Particles.js

WebDeg-Brian commented 5 years ago

I also tried this code and notice that the possibilities of the density failure decrease. But still, it happens

import React from 'react';

import styled from 'styled-components';

import ParticlesCanvas from 'react-particles-js';

const StyledParticlesWrapper = styled(ParticlesCanvas)`
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
`;

export default Particles = props => {
  return (
    <StyledParticlesWrapper params={{
        particles: {
          number: {
            value: 80,
            density: {
              enable: true,
              value_area: 800
            }
          }
        }
      }} />
  );
}
wufe commented 5 years ago

There was a bug creating a concurrency of events. This bug has been resolved and will be included in next release (v2.4.0)