Skip to content

Commit

Permalink
fix: 🐛 can not select flat edge (#1394)
Browse files Browse the repository at this point in the history
  • Loading branch information
NewByVector authored Oct 1, 2021
1 parent 175aa58 commit 89ae2cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/x6/src/graph/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,11 @@ export class Renderer extends Base {
const bbox = Dom.getBBox(view.container as SVGElement, {
target: this.view.stage,
})
if (bbox.width === 0) {
bbox.inflate(1, 0)
} else if (bbox.height === 0) {
bbox.inflate(0, 1)
}
return options.strict
? area.containsRect(bbox)
: area.isIntersectWithRect(bbox)
Expand Down
5 changes: 5 additions & 0 deletions packages/x6/src/model/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,11 @@ export class Model extends Basecoat<Model.EventArgs> {
const strict = opts && opts.strict
return this.getEdges().filter((edge) => {
const bbox = edge.getBBox()
if (bbox.width === 0) {
bbox.inflate(1, 0)
} else if (bbox.height === 0) {
bbox.inflate(0, 1)
}
return strict ? rect.containsRect(bbox) : rect.isIntersectWithRect(bbox)
})
}
Expand Down

0 comments on commit 89ae2cc

Please sign in to comment.