-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat: allow calculate distance by bbox when snap to node #4126
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #4126 +/- ##
=======================================
Coverage 10.37% 10.38%
=======================================
Files 180 180
Lines 10542 10548 +6
Branches 2566 2567 +1
=======================================
+ Hits 1094 1095 +1
- Misses 9359 9364 +5
Partials 89 89
Flags with carried forward coverage won't be shown. Click here to find out more.
|
packages/x6/src/graph/options.ts
Outdated
@@ -109,7 +109,7 @@ export namespace Options { | |||
/** | |||
* Snap edge to the closest node/port in the given radius on dragging. | |||
*/ | |||
snap: boolean | { radius: number } | |||
snap: boolean | { radius: number; snapNode: 'center' | 'bbox' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
很棒的配置!👍 有一个小的建议,将 snapNode
名称修改为 anchor
会更好。
@@ -48,6 +48,8 @@ const graph = new Graph({ | |||
}) | |||
``` | |||
|
|||
当开启了 `allowNode` 时,判断是否吸附到节点计算distance时默认为基于节点的中心,可以通过配置 `snapNode` 为 `bbox` 改为基于节点的包围盒子计算距离。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
另外,这个文档文本可以优化一下。当开启了 allowNode 时,这个前提可以去掉。
👍 感谢建议,已修改。 |
Description
完成 https://github.com/antvis/X6/issues/3963,支持吸附到节点时基于bbox计算距离
Close #3963
Motivation and Context
当吸附到边时,默认为基于最近距离计算,但是吸附到节点时默认为基于节点中心点计算距离且不支持配置。针对连接到母线这种情况吸附到中心点的体验比较差,因此新增了配置项
snapNode
, 默认为center
, 可配置为bbox
, 默认值保留原来的行为,配置为bbox
时基于包围框距离判断是否吸附。Types of changes
Self Check before Merge