antvis / g6-editor

532 stars 172 forks source link

关于节点动画,想在节点上加上linedash,可以显示运动动画,g6文档中有提及,但是在g6-editor中不生效 #125

Open gzhanghui opened 5 years ago

gzhanghui commented 5 years ago

对应文档-点线运动


afterDraw(cfg, group) {
      const shape = group.get('children')[0];
      const length = 200; //先写死,后续 G 增加 totalLength 的接口
      let totalArray = [];
      // 计算出整条线的 lineDash
      for (var i = 0; i < length; i += interval) {
        totalArray = totalArray.concat(lineDash);
      }
      let index = 0;
      shape.animate({
        onFrame(ratio) {
          const cfg = {
            lineDash: dashArray[index].concat(totalArray)
          };
          index = (index + 1) % interval;
          return cfg;
        },
        repeat: true
      }, 3000);
    }