Skip to content

Commit

Permalink
fix: get wrong anchor when a node is invisible (#4313)
Browse files Browse the repository at this point in the history
  • Loading branch information
leondt1 authored May 21, 2024
1 parent 4eea5ef commit c5d19fd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
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

0 comments on commit c5d19fd

Please sign in to comment.