Set mxgraph cell only draggable within the canvas width

你说的曾经没有我的故事 提交于 2021-01-29 06:01:01

问题


I have multiple vertex cells in the graph. I am using JavaScript library mxGraph. When i drag the cell from the boundary of canvas, the canvas extends. I want to disallow the cell drag. Is there some function available to limit the drag within the canvas boundaries?

There is function called: graph.setCellsMovable(false); but this one lock overall, i need to set cell movement false only if user drag it outside the boundary.


回答1:


You should give a try to the mxgraph.autoExtend property which seems to configure exactly what you are looking for

https://jgraph.github.io/mxgraph/docs/js-api/files/view/mxGraph-js.html#mxGraph.autoExtend

Specifies if the size of the graph should be automatically extended if the mouse goes near the container edge while dragging. This is only taken into account if the container has scrollbars. Default is true.

There are also other configuration properties about auto extend, like https://jgraph.github.io/mxgraph/docs/js-api/files/view/mxGraph-js.html#mxGraph.extendParentsOnAdd



来源:https://stackoverflow.com/questions/64805220/set-mxgraph-cell-only-draggable-within-the-canvas-width

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!