cytoscape.js 禁用抓取和移动节点

cytoscape.js disable grab&moving nodes

我在使用 cytoscapeJS 构建图形网络时遇到问题。 我可以添加节点并处理它们,这非常简单,但我无法配置细胞空间来禁用 Dragging/Moving 个节点。

我从某人那里找到了一个 JSbin,您可以在其中尝试:http://jsbin.com/vasenatimu/2/edit?html,js,output

看看'Initialisation options'下的http://js.cytoscape.org,我尝试了所有选项,但它们没有解决我的问题(我几乎将所有选项都设置为false,但我仍然可以抓取和select 节点).

你能帮我解决这个问题吗?

initOptions.autoungrabify: truecy.nodes().ungrabify()

您还可以使用所选节点的配置来禁用它们。例如:

cytoscape({
  elements: {
    nodes: [
      { 
        data: { id: "node1" }, 
        grabbable: false,
      },
    ],
  },
});

我遇到了同样的问题,我发现这是解决我问题的方法:

cytoscape({
  autolock: true, <== this did the trick for me
  elements: {
    nodes: [
      { 

      },
    ],
  },
});

希望这对你也有帮助。

问候埃德加