javascriptmxgraph

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


Solution

  • 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:

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