Skip to content

Commit

Permalink
feat: find view
Browse files Browse the repository at this point in the history
  • Loading branch information
bubkoo committed Jun 12, 2020
1 parent ec584ac commit 425c6af
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/x6/src/geometry/rectangle.ts
Expand Up @@ -761,4 +761,15 @@ export namespace Rectangle {
2 * ellipse.b,
)
}

export function isRectangleLike(o: any): o is RectangleLike {
return (
o != null &&
typeof o === 'object' &&
typeof o.x === 'number' &&
typeof o.y === 'number' &&
typeof o.width === 'number' &&
typeof o.height === 'number'
)
}
}
18 changes: 18 additions & 0 deletions packages/x6/src/graph/graph.ts
Expand Up @@ -472,6 +472,24 @@ export class Graph extends Basecoat<EventArgs> {
return this.renderer.isAsync()
}

findView(
ref: Cell | JQuery | Element | Point.PointLike | Rectangle.RectangleLike,
) {
if (ref instanceof Cell) {
return this.findViewByCell(ref)
}

if (Rectangle.isRectangleLike(ref)) {
return this.findViewsInArea(ref)
}

if (Point.isPointLike(ref)) {
return this.findViewsFromPoint(ref)
}

return this.findViewByElem(ref)
}

findViewByCell(cellId: string | number): CellView | null
findViewByCell(cell: Cell | null): CellView | null
findViewByCell(
Expand Down

0 comments on commit 425c6af

Please sign in to comment.