Skip to content

如何根据不同节点展示不同的连线样式? #4175

Closed Answered by LuoYuChenZhou
LuoYuChenZhou asked this question in Q&A
Discussion options

You must be logged in to vote

找到另外个方法了,上面说的createEdge中,不设置特殊逻辑了,改成在连线的时候加监听实现了

    _graph.on('edge:connected', ({ edge, isNew }) => {
      // 判断连线的两个节点,是否都是主流程节点,如果是的话,就加上特定效果
      const sourceShape = edge.getSourceNode()?.shape || '';
      const targetShape = edge.getTargetNode()?.shape || '';

      if (flowNodeTypes.indexOf(sourceShape) > -1 && flowNodeTypes.indexOf(targetShape) > -1) {
        edge.attr('line/stroke', '#8f8f8f');
        edge.attr('line/strokeWidth', 2);
        edge.attr('line/style', {
          animation: 'ant-line 30s infinite linear',
        });
        edge.attr('line/strokeDasharray', 5);
      }
    });
  };

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by LuoYuChenZhou
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant