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

fix: get wrong anchor when a node is invisible #4313

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/x6/src/registry/node-anchor/bbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ function createBBoxAnchor(
| 'bottomRight',
): NodeAnchor.Definition<BBoxEndpointOptions> {
return function (view, magnet, ref, options: BBoxEndpointOptions = {}) {
const bbox = options.rotate
? view.getUnrotatedBBoxOfElement(magnet)
: view.getBBoxOfElement(magnet)
let bbox
if (view.cell.visible) {
bbox = options.rotate
? view.getUnrotatedBBoxOfElement(magnet)
: view.getBBoxOfElement(magnet)
} else {
bbox = view.cell.getBBox()
}
const result = bbox[method]

result.x += NumberExt.normalizePercentage(options.dx, bbox.width)
Expand Down
6 changes: 5 additions & 1 deletion packages/x6/src/registry/node-anchor/middle-side.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ const middleSide: NodeAnchor.ResolvedDefinition<MiddleSideEndpointOptions> =
center = node.getBBox().getCenter()
angle = node.getAngle()
} else {
bbox = view.getBBoxOfElement(magnet)
if (node.visible) {
bbox = view.getBBoxOfElement(magnet)
} else {
bbox = view.cell.getBBox()
}
}

const padding = options.padding
Expand Down
4 changes: 3 additions & 1 deletion packages/x6/src/registry/node-anchor/orth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export interface OrthEndpointOptions extends ResolveOptions {
const orthogonal: NodeAnchor.ResolvedDefinition<OrthEndpointOptions> =
function (view, magnet, refPoint, options) {
const angle = Angle.normalize(view.cell.getAngle())
const bbox = view.getBBoxOfElement(magnet)
const bbox = view.cell.visible
? view.getBBoxOfElement(magnet)
: view.cell.getBBox()
const result = bbox.getCenter()
const topLeft = bbox.getTopLeft()
const bottomRight = bbox.getBottomRight()
Expand Down
Loading