加节点时,新节点的位置不对 #4627
neolee6053 posted onGitHub
问题描述
加节点时,新节点的位置不对(尤其是zoom in / zoom out 后)
G6.registerBehavior("click-add-textnode", {
// Bind the events and response functions for this custom Behavior
getEvents() {
return {
"canvas:dblclick": "onDblClick" // The event to be listned is canvas:click. The response function is onClick
};
},
// The click event
onDblClick(ev) {
const graph = this.graph;
// Add a new node on the canvas
const node = this.graph.addItem("node", {
x: ev.canvasX,
y: ev.canvasY,
id: node-${addedTextNodeCount}
, // Generate a unique id
label: "New text",
size: 1
});
addedTextNodeCount++;
}
});
重现链接
https://codesandbox.io/s/g6-p6fq42?file=/index.js:13322-13929
重现步骤
如上
预期行为
如上
平台
- 操作系统: [ Windows]
- 网页浏览器: [Google Chrome,]
- G6 版本: [4.8.15 ]
屏幕截图或视频(可选)
No response
补充说明(可选)
No response