'Detect if a node when dropped/moved intersects another node - mxgraph
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);
}
};
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
