在cytoscape.js中禁用将节点拖到区域之外 [英] Disable dragging nodes outside of area in cytoscape.js

查看:168
本文介绍了在cytoscape.js中禁用将节点拖到区域之外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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'.

我在 http://js.cytoscape.org/#core/initialisation ,但我不知道如何确保节点不能离开可见区域< div id = cy>< / div>

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>.

推荐答案

尝试使用automove扩展名: https://github.com/cytoscape/cytoscape.js-automove

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.

这篇关于在cytoscape.js中禁用将节点拖到区域之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆