test: find start and end point

This commit is contained in:
Yanyan-Wang 2020-03-10 11:13:34 +08:00 committed by Yanyan Wang
parent b048eea057
commit 8f21d9e650
3 changed files with 7 additions and 1 deletions

View File

@ -52,11 +52,13 @@ export default class Edge extends Item implements IEdge {
const pointName = END_MAP[name] + POINT_NAME_SUFFIX;
const itemName = name + ITEM_NAME_SUFFIX;
let point = this.get(pointName);
console.log('get link point', point);
if (!point) {
const item = this.get(itemName);
const anchorName = name + ANCHOR_NAME_SUFFIX;
const prePoint = this.getPrePoint(name, controlPoints);
const anchorIndex = model[anchorName];
console.log('!isNil(anchorIndex)', !isNil(anchorIndex));
if (!isNil(anchorIndex)) {
// 如果有锚点,则使用锚点索引获取连接点
point = item.getLinkPointByAnchor(anchorIndex);
@ -67,6 +69,7 @@ export default class Edge extends Item implements IEdge {
this.set(`${name}AnchorIndex`, point.index);
}
}
console.log('get link point final', point, model);
return point;
}
@ -151,6 +154,7 @@ export default class Edge extends Item implements IEdge {
}
cfg.sourceNode = self.get('sourceNode');
cfg.targetNode = self.get('targetNode');
console.log('returning cfg', cfg);
return cfg;
}

View File

@ -83,6 +83,7 @@ export default class Node extends Item implements INode {
const { centerX, centerY } = bbox;
const anchorPoints = this.getAnchorPoints();
let intersectPoint: IPoint | null;
console.log('getLinkPoint', point, type, centerX, centerY, bbox.width);
switch (type) {
case 'circle':
intersectPoint = getCircleIntersectByPoint(
@ -108,6 +109,7 @@ export default class Node extends Item implements INode {
default:
intersectPoint = getRectIntersectByPoint(bbox, point);
}
console.log('intersectPoint', intersectPoint);
let linkPoint = intersectPoint;
// 如果存在锚点,则使用交点计算最近的锚点
if (anchorPoints.length) {

View File

@ -338,7 +338,7 @@ describe('dagre layout', () => {
},
renderer: 'svg',
defaultEdge: {
type: 'polyline',
type: 'line',
style: {
radius: 20,
},