如何创建带有浮动圆圈和文本的动画?

时间:2019-06-05 13:25:25

标签: javascript

我正在尝试创建this之类的气泡动画。

我使用particles.js,但是无法在圆内插入文本。气泡必须像here一样平稳地移动。

初始化粒子.js

function runParticles(id) {

  particlesJS(id, {

    "particles": {
      "number": {
        "value": 1,
        "density": {
          "enable": true,
          "value_area": 40
        }
      },
      "color": {
        "value": "#ffffff"
      },
      "shape": {
        "type": "image",
        "stroke": {
          "width": 0,
          "color": "#000000"
        },
        "polygon": {
          "nb_sides": 1
        },
        "image": {
          "src": pref + "/bubble.png"
        }
      },
      "opacity": {
        "value": 1,
        "random": false,
        "anim": {
          "enable": false,
          "speed": 1,
          "opacity_min": 0.1,
          "sync": false
        }
      },
      "size": {
        "value": 155,
        "random": true,
        "anim": {
          "enable": false,
          "speed": 80,
          "size_min": 0.1,
          "sync": false
        }
      },
      "line_linked": {
        "enable": true,
        "distance": 400,
        "color": "#ffffff",
        "opacity": 1,
        "width": 0
      },
      "move": {
        "enable": true,
        "speed": 3,
        "direction": "none",
        "random": false,
        "straight": false,
        "out_mode": "bounce",
        "bounce": true,
        "attract": {
          "enable": false,
          "rotateX": 100,
          "rotateY": 100
        }
      }
    },
    "interactivity": {
      "detect_on": "canvas",
      "events": {
        "onhover": {
          "enable": true,
          "mode": "grab"
        },
        "onclick": {
          "enable": false,
          "mode": "repulse"
        },
        "resize": true
      },
      "modes": {
        "grab": {
          "distance": 40,
          "line_linked": {
            "opacity": 1
          }
        },
        "bubble": {
          "distance": 400,
          "size": 40,
          "duration": 2,
          "opacity": 1,
          "speed": 3
        },
        "repulse": {
          "distance": 60,
          "duration": 0.4
        },
        "push": {
          "particles_nb": 4
        },
        "remove": {
          "particles_nb": 2
        }
      }
    },
    "retina_detect": true
  });
}


runParticles('particles-js');

用户单击气泡时,应将其重定向到另一个页面。

如何在移动气泡中放置一些文本并创建链接以便将用户重定向到另一个页面?

在此先感谢您的帮助:)

1 个答案:

答案 0 :(得分:2)

看起来particel.js仅用于创建本质上不具有纹理的粒子。也许threejs为此更好地工作