Disable dragging nodes outside of area in cytoscape.js

一曲冷凌霜 提交于 2020-05-18 08:28:44

问题


I am using cytoscape.js.

I have allowed the user to drag the nodes, but right now it is also possible to drag the node outside of the 'canvas'.

I have looked at the options at http://js.cytoscape.org/#core/initialisation but I don't know how to make sure the nodes cannot leave the visible area <div id="cy"></div>.


回答1:


Try the automove extension: https://github.com/cytoscape/cytoscape.js-automove

It lets you set rules for node position, like constraining within the current viewport or a specified region.



来源:https://stackoverflow.com/questions/39280268/disable-dragging-nodes-outside-of-area-in-cytoscape-js

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