简体   繁体   English

mxGraph 如何阻止边缘被拖动?

[英]mxGraph how to stop edges from being dragged?

I have a simple graph and would like to prevent users from being able to drag the edges whilst still allowing them the ability to drag the nodes (with the edges adjusting as they currently are).我有一个简单的图形,并希望阻止用户拖动边缘,同时仍然允许他们拖动节点的能力(边缘调整为当前状态)。 I have almost achieved this by disabling selection but can not figure out how to get rid of edge dragging functionality.我几乎通过禁用选择来实现这一点,但无法弄清楚如何摆脱边缘拖动功能。

Codesandbox 代码沙盒

There are at least two ways to achive that.至少有两种方法可以实现这一目标。 One will be setting it in default edge style:一种是将其设置为默认边缘样式:

style[mxConstants.STYLE_MOVABLE] = 0;

Another way would be to override isCellMovable to not allow moving the cell if it is an edge:另一种方法是覆盖isCellMovable以不允许移动单元格(如果它是边缘):

graph.isCellMovable = function(cell){
    return !cell.isEdge();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM