@antv/x6
Version:
JavaScript diagramming library that uses SVG and HTML for rendering
39 lines (34 loc) • 956 B
text/typescript
import { FunctionExt } from '../../common'
import type { PointLike } from '../../geometry'
import type { TerminalCellData, TerminalType } from '../../model/edge'
import type { CellView } from '../../view/cell'
import type { EdgeView } from '../../view/edge'
import { connectionStrategyPresets } from '../connection-strategy'
export function getAnchor(
this: EdgeView,
pos: PointLike,
terminalView: CellView,
terminalMagnet: Element,
type: TerminalType,
) {
const end = FunctionExt.call(
connectionStrategyPresets.pinRelative,
this.graph,
{} as TerminalCellData,
terminalView,
terminalMagnet,
pos,
this.cell,
type,
{},
)
return end.anchor
}
export function getViewBBox(view: CellView, quick?: boolean) {
if (quick) {
return view.cell.getBBox()
}
return view.cell.isEdge()
? (view as EdgeView).getConnection()!.bbox()!
: view.getUnrotatedBBoxOfElement(view.container as SVGElement)
}