* 给边自定义方案,使其支持基于锚点的位置更新边的路径
()
| 201 | * 给边自定义方案,使其支持基于锚点的位置更新边的路径 |
| 202 | */ |
| 203 | updatePathByAnchor() { |
| 204 | const sourceNodeModel = this.graphModel.getNodeModelById(this.sourceNodeId) |
| 205 | const sourceAnchor = sourceNodeModel |
| 206 | .getDefaultAnchor() |
| 207 | .find((anchor: any) => anchor.id === this.sourceAnchorId) |
| 208 | |
| 209 | const targetNodeModel = this.graphModel.getNodeModelById(this.targetNodeId) |
| 210 | const targetAnchor = targetNodeModel |
| 211 | .getDefaultAnchor() |
| 212 | .find((anchor: any) => anchor.id === this.targetAnchorId) |
| 213 | if (sourceAnchor && targetAnchor) { |
| 214 | const startPoint = { |
| 215 | x: sourceAnchor.x, |
| 216 | y: sourceAnchor.y, |
| 217 | } |
| 218 | this.updateStartPoint(startPoint) |
| 219 | const endPoint = { |
| 220 | x: targetAnchor.x, |
| 221 | y: targetAnchor.y, |
| 222 | } |
| 223 | |
| 224 | this.updateEndPoint(endPoint) |
| 225 | } |
| 226 | |
| 227 | // 这里需要将原有的pointsList设置为空,才能触发bezier的自动计算control点。 |
| 228 | this.pointsList = [] |
| 229 | this.initPoints() |
| 230 | } |
| 231 | setAttributes(): void { |
| 232 | super.setAttributes() |
| 233 | this.isHitable = true |
no test coverage detected