Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义节点面板拖入节点不触发新增,而是要多点击一次才行。 #267

Closed
towersxu opened this issue Aug 16, 2021 · 3 comments
Labels

Comments

@towersxu
Copy link
Collaborator

towersxu commented Aug 16, 2021

有时候还会出现警告
GraphModel.ts:389 不存在id为xxx的节点

@towersxu towersxu added the FAQ label Aug 16, 2021
@towersxu
Copy link
Collaborator Author

towersxu commented Aug 16, 2021

出现这个问题的原因是LogicFlow通过监听document上的mouseup获取拖动添加节点时鼠标松开的位置,然后去对应的位置添加这个节点。

startDrag(nodeConfig: NewNodeConfig) {
this.nodeConfig = nodeConfig;
window.document.addEventListener('mouseup', this.stopDrag);
}

如果我们自定义拖动面板的时候采用图片作为拖动添加的触发元素(或者其子节点),那么在拖动添加节点的时候,就可能同时拖动图片进画布了。这就会导致鼠标松开的时候,不会触发document上的mouseup事件。所以需要多点击一次才行。

解决办法:
只要保证拖动结束的mouseup能正常触发就行。

  1. 如果是用图片作为触发元素,可以考虑设置dragable为false或者将其作为背景图。
  2. 如果触发元素被a标签包裹,获取其它可以拖动的元素。这个时候可以设置user-select: none。

@kanglixia
Copy link

纠正一下:dragable:false的单词写错了~正确的是:draggable:false

@towersxu
Copy link
Collaborator Author

#185

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants