【问题标题】:How to loop the edge animation to marching ant in cytoscape.js如何在 cytoscape.js 中将边缘动画循环到行军蚂蚁
【发布时间】:2021-12-31 17:15:23
【问题描述】:

如何使边缘像行军蚂蚁一样动画并将其指向目标节点?

我尝试像这样使用line-dash-offset 属性,但它没有循环。

风格

{
      selector: "edge",
      style: {
        "curve-style": "taxi",
        width: 2,
        "target-arrow-shape": "triangle",
        "target-arrow-color": "#9dbaea",
        "line-style": "dashed",
        "line-dash-pattern": [8, 4],
      }
    }

动画

let loopAnimation = eles => {
  eles.animation(
      {
        style: {
          "line-dash-offset": 24,
          "line-dash-pattern": [8, 4],
        }
      },
      {
        duration: 1000
      }
  ).play().promise('complete').then(() => loopAnimation(eles))
};

cy.edges().forEach(loopAnimation);

【问题讨论】:

    标签: javascript diagram cytoscape.js


    【解决方案1】:

    我可以在你播放之前调用 reverse() 来解决这个问题

    let loopAnimation = eles => {
      const ani = eles.animation(
          {
            style: {
              "line-dash-offset": 24,
              "line-dash-pattern": [8, 4],
            }
          },
          {
            duration: 1000
          }
      );
    
      ani.reverse().play().promise('complete').then(() => loopAnimation(eles))
    };
    

    【讨论】:

      猜你喜欢
      • 2015-04-25
      • 1970-01-01
      • 2012-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多