检测删除/移动时的节点是否与另一个节点相交 - mxgraph
当您移动一个细胞时,我正在尝试检测细胞节点的任何部分是否与另一个单元格相交,并且其某些身体与另一个节点相交。我尝试编写自己的自定义mouseup
函数,以便如果有一些交叉点,我会显示一个错误,说允许它。以下是我编写的代码。它不能完美地工作。有一次它运行良好的是,如果我在另一个节点上放置一个节点,而有时我将一个节点放在另一个节点的远处时,则无法正常工作。
const mouseUp = graph.graphHandler.mouseUp;
graph.graphHandler.mouseUp = function(...args) {
const target = graph.getCellAt(args[1].graphX, args[1].graphY);
if (target) {
alert('not allowed');
graph.graphHandler.reset();
} else {
mouseUp.apply(this, args);
}
};
I am trying to detect if any part of cell node intersects with another cell when u move a cell and some of its body intersects with another node. I tried to write my own custom mouseUp
function such that if the there's some intersection, I'll display an error saying that its allowed. Below is the code i wrote. It doesn't work perfectly. one time when it works well is if I put a node on the center on another node but other times when I put a node on the far edge of another node it doesn't work.
const mouseUp = graph.graphHandler.mouseUp;
graph.graphHandler.mouseUp = function(...args) {
const target = graph.getCellAt(args[1].graphX, args[1].graphY);
if (target) {
alert('not allowed');
graph.graphHandler.reset();
} else {
mouseUp.apply(this, args);
}
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论