Jump to content

PARTICLES.JS need help integrating the code throughout my whole site.

Recommended Posts

Posted

I'm trying to integrate the particles JS code onto my whole site but it does not work. I do see the animation when i'm saving changes on my site for a split second but it disappears. and it seems to only appear on the home page but would like the particles.js animation throughout my site.

 

I only put it as a code injection (see attached)

 

Here is the code but below it I've generated a new code I would like to implement:

<script>

  document.addEventListener('DOMContentLoaded', function() {

    var section = document.querySelector('.section-background');

    var div = document.createElement('div');

    div.id = 'particles-js';

    div.style.width = '100%';

    div.style.height = '100%';

    div.style.position = 'absolute';

    section.prepend(div);

    particlesJS('particles-js', particlesJSConfig);

    setTimeout(function() { window.dispatchEvent(new Event('resize')); }, 100);

  });

</script>
<script>
  var particlesJSConfig =
 {
  "particles": {
    "number": {
      "value": 400,
      "density": {
        "enable": true,
        "value_area": 800
      }
    },
    "color": {
      "value": "#242f4f"
    },
    "shape": {
      "type": "circle",
      "stroke": {
        "width": 0,
        "color": "#000000"
      },
      "polygon": {
        "nb_sides": 5
      },
      "image": {
        "src": "img/github.svg",
        "width": 100,
        "height": 100
      }
    },
    "opacity": {
      "value": 0.5,
      "random": true,
      "anim": {
        "enable": false,
        "speed": 1,
        "opacity_min": 0.1,
        "sync": false
      }
    },
    "size": {
      "value": 1,
      "random": false,
      "anim": {
        "enable": true,
        "speed": 0,
        "size_min": 0,
        "sync": false
      }
    },
    "line_linked": {
      "enable": false,
      "distance": 500,
      "color": "#ffffff",
      "opacity": 0.4,
      "width": 2
    },
    "move": {
      "enable": true,
      "speed": 6,
      "direction": "none",
      "random": true,
      "straight": false,
      "out_mode": "bounce",
      "bounce": false,
      "attract": {
        "enable": false,
        "rotateX": 600,
        "rotateY": 1200
      }
    }
  },
  "interactivity": {
    "detect_on": "canvas",
    "events": {
      "onhover": {
        "enable": true,
        "mode": "repulse"
      },
      "onclick": {
        "enable": true,
        "mode": "repulse"
      },
      "resize": true
    },
    "modes": {
      "grab": {
        "distance": 400,
        "line_linked": {
          "opacity": 0.5
        }
      },
      "bubble": {
        "distance": 400,
        "size": 4,
        "duration": 0.3,
        "opacity": 1,
        "speed": 3
      },
      "repulse": {
        "distance": 200,
        "duration": 0.4
      },
      "push": {
        "particles_nb": 4
      },
      "remove": {
        "particles_nb": 2
      }
    }
  },
  "retina_detect": true
}

</script>

 

NEW CODE:

 

{

  "particles": {

    "number": {

      "value": 80,

      "density": {

        "enable": true,

        "value_area": 552.4033491425909

      }

    },

    "color": {

      "value": "#252e4d"

    },

    "shape": {

      "type": "circle",

      "stroke": {

        "width": 0,

        "color": "#000000"

      },

      "polygon": {

        "nb_sides": 5

      },

      "image": {

        "src": "img/github.svg",

        "width": 100,

        "height": 100

      }

    },

    "opacity": {

      "value": 0.5,

      "random": true,

      "anim": {

        "enable": false,

        "speed": 1,

        "opacity_min": 0.1,

        "sync": false

      }

    },

    "size": {

      "value": 2,

      "random": true,

      "anim": {

        "enable": false,

        "speed": 40,

        "size_min": 0.1,

        "sync": false

      }

    },

    "line_linked": {

      "enable": false,

      "distance": 500,

      "color": "#252e4d",

      "opacity": 0.4,

      "width": 2

    },

    "move": {

      "enable": true,

      "speed": 4,

      "direction": "none",

      "random": true,

      "straight": false,

      "out_mode": "out",

      "bounce": false,

      "attract": {

        "enable": false,

        "rotateX": 600,

        "rotateY": 631.3181133058181

      }

    }

  },

  "interactivity": {

    "detect_on": "window",

    "events": {

      "onhover": {

        "enable": true,

        "mode": "repulse"

      },

      "onclick": {

        "enable": true,

        "mode": "repulse"

      },

      "resize": true

    },

    "modes": {

      "grab": {

        "distance": 400,

        "line_linked": {

          "opacity": 0.5

        }

      },

      "bubble": {

        "distance": 400,

        "size": 4,

        "duration": 0.3,

        "opacity": 1,

        "speed": 3

      },

      "repulse": {

        "distance": 129.92496833078906,

        "duration": 0.4

      },

      "push": {

        "particles_nb": 4

      },

      "remove": {

        "particles_nb": 2

      }

    }

  },

  "retina_detect": true

}

 

 

Screenshot 2023-07-05 at 1.03.35 PM.png

  • Replies 0
  • Views 489
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Posted Images

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.