Disable dragging nodes outside of area in cytoscape.js
问题 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