* 给边自定义方案,使其支持基于锚点的位置更新边的路径
()
| 31 | * 给边自定义方案,使其支持基于锚点的位置更新边的路径 |
| 32 | */ |
| 33 | updatePathByAnchor() { |
| 34 | // TODO |
| 35 | const sourceNodeModel = this.graphModel.getNodeModelById(this.sourceNodeId) |
| 36 | const sourceAnchor = sourceNodeModel |
| 37 | .getDefaultAnchor() |
| 38 | .find((anchor: any) => anchor.id === this.sourceAnchorId) |
| 39 | |
| 40 | const targetNodeModel = this.graphModel.getNodeModelById(this.targetNodeId) |
| 41 | const targetAnchor = targetNodeModel |
| 42 | .getDefaultAnchor() |
| 43 | .find((anchor: any) => anchor.id === this.targetAnchorId) |
| 44 | if (sourceAnchor && targetAnchor) { |
| 45 | const startPoint = { |
| 46 | x: sourceAnchor.x, |
| 47 | y: sourceAnchor.y - 10 |
| 48 | } |
| 49 | this.updateStartPoint(startPoint) |
| 50 | const endPoint = { |
| 51 | x: targetAnchor.x, |
| 52 | y: targetAnchor.y + 3 |
| 53 | } |
| 54 | |
| 55 | this.updateEndPoint(endPoint) |
| 56 | } |
| 57 | |
| 58 | // 这里需要将原有的pointsList设置为空,才能触发bezier的自动计算control点。 |
| 59 | this.pointsList = [] |
| 60 | this.initPoints() |
| 61 | } |
| 62 | setAttributes(): void { |
| 63 | super.setAttributes() |
| 64 | this.isHitable = true |
nothing calls this directly
no test coverage detected