Merge pull request #857 from antvis/dev3.1.0

修复当自定义的节点中心位置不在中心点时delegate错位的问题
This commit is contained in:
Moyee 2019-10-05 17:17:03 +08:00 committed by GitHub
commit d8ccff10e6
2 changed files with 19 additions and 15 deletions

View File

@ -481,6 +481,9 @@
container: 'mountNode',
width: 800,
height: 600,
modes: {
default: ['drag-node']
},
defaultNode: {
shape: 'card-node'
}

View File

@ -194,29 +194,30 @@ module.exports = {
attrs: {
width: bbox.width,
height: bbox.height,
x: x - bbox.width / 2,
y: y - bbox.height / 2,
x: x + bbox.x,
y: y + bbox.y,
...attrs
}
});
this.target.set('delegateShape', this.shape);
}
this.shape.set('capture', false);
} else {
if (this.targets.length > 0) {
const clientX = e.x - this.origin.x + this.originPoint.minX;
const clientY = e.y - this.origin.y + this.originPoint.minY;
this.shape.attr({
x: clientX,
y: clientY
});
} else if (this.target) {
this.shape.attr({
x: x + bbox.x,
y: y + bbox.y
});
}
}
if (this.targets.length > 0) {
const clientX = e.x - this.origin.x + this.originPoint.minX;
const clientY = e.y - this.origin.y + this.originPoint.minY;
this.shape.attr({
x: clientX,
y: clientY
});
} else if (this.target) {
this.shape.attr({
x: x - bbox.width / 2,
y: y - bbox.height / 2
});
}
this.graph.paint();
},
/**