particles.js 重启或运行多个实例?

问题描述

谁能弄清楚如何多次运行此功能或以某种方式重新启动它?因为当我再次尝试使用它时,它似乎只运行一次,然后抛出“pJS 不是函数”的错误。还有最有效的方法是什么? https://github.com/VincentGarreau/particles.js/

示例:https://jsfiddle.net/MatrX/rfd7es3y/

/* ---------- particles.js SETTINGS ------------ */
    function particles_bg(id){
        pJS(id,{
          "particles": {
            "number": {
              "value": 1500,"density": {
                "enable": true,"value_area": 700
              }
            },"color": {
              "value": "#ffffff"
            },"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": false,"anim": {
                "enable": true,"speed": 0.2,"opacity_min": 0,"sync": false
              }
            },"size": {
              "value": 2,"random": true,"speed": 2,"size_min": 0,"line_linked": {
              "enable": false,"distance": 150,"color": "#ffffff","opacity": 0.4,"width": 1
            },"move": {
              "enable": true,"direction": "none","straight": false,"out_mode": "out","bounce": false,"attract": {
                "enable": false,"rotateX": 600,"rotateY": 1200
              }
            }
          },"interactivity": {
            "detect_on": "canvas","events": {
              "onhover": {
                "enable": true,"mode": "bubble"
              },"onclick": {
                "enable": true,"mode": "push"
              },"resize": true
            },"modes": {
              "grab": {
                "distance": 400,"line_linked": {
                  "opacity": 1
                }
              },"bubble": {
                "distance": 85,"size": 1,"duration": 3,"opacity": 1,"speed": 3
              },"repulse": {
                "distance": 200,"duration": 0.4
              },"push": {
                "particles_nb": 4
              },"remove": {
                "particles_nb": 2
              }
            }
          },"retina_detect": true
        });
        //document.getElementById("pJS").remove();

    }
/* ---------- particles.js RUN ------------ */
particles_bg('p1');
particles_bg('p2');

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)