微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。