GGEditor
GGEditor copied to clipboard
如何实现只允许输出锚点连接输入锚点
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;
}
});
同问!
同问!
同问 @gaoli
同问 大佬
参考这个DEMO https://github.com/gaoli/GGEditor/issues/253
参考这个DEMO #253
同问!
请问下你实现了吗?
同问!
请问你是实现了吗?
同问!
请问你是实现了吗?
实现了,一种 walk around的方式
同问!
请问你是实现了吗?
实现了,一种走走的方式
请问您如何实现的,我目前也遇到了这个问题