GGEditor icon indicating copy to clipboard operation
GGEditor copied to clipboard

如何实现只允许输出锚点连接输入锚点

Open SwordsmanYao opened this issue 7 years ago • 9 comments

g6-editor中是这样实现的,在gg里面怎么写呢:

const page = editor.getCurrentPage();
// 输入锚点不可以连出边
page.on('hoveranchor:beforeaddedge', ev => {
  if (ev.anchor.type === 'input') {
    ev.cancel = true;
  }
});
page.on('dragedge:beforeshowanchor', ev => {
  // 只允许目标锚点是输入,源锚点是输出,才能连接
  if (!(ev.targetAnchor.type === 'input' && ev.sourceAnchor.type === 'output')) {
    ev.cancel = true;
  }
  // 如果拖动的是目标方向,则取消显示目标节点中已被连过的锚点
  if (ev.dragEndPointType === 'target' && page.anchorHasBeenLinked(ev.target, ev.targetAnchor)) {
    ev.cancel = true;
  }
  // 如果拖动的是源方向,则取消显示源节点中已被连过的锚点
  if (ev.dragEndPointType === 'source' && page.anchorHasBeenLinked(ev.source, ev.sourceAnchor)) {
    ev.cancel = true;
  }
});

SwordsmanYao avatar Jan 11 '19 07:01 SwordsmanYao

同问!

MengyanGuo avatar May 17 '19 08:05 MengyanGuo

同问!

zibu15 avatar Jun 04 '19 18:06 zibu15

同问 @gaoli

wisewrong avatar Jun 19 '19 06:06 wisewrong

同问 大佬

kevinlee22 avatar Jun 20 '19 08:06 kevinlee22

参考这个DEMO https://github.com/gaoli/GGEditor/issues/253

titanzhi avatar Jun 27 '19 06:06 titanzhi

参考这个DEMO #253

同问!

请问下你实现了吗?

hanruiying avatar Sep 19 '19 02:09 hanruiying

同问!

请问你是实现了吗?

hanruiying avatar Sep 19 '19 02:09 hanruiying

同问!

请问你是实现了吗?

实现了,一种 walk around的方式

zibu15 avatar Sep 20 '19 04:09 zibu15

同问!

请问你是实现了吗?

实现了,一种走走的方式

请问您如何实现的,我目前也遇到了这个问题

fx-Aice avatar Sep 21 '20 10:09 fx-Aice