Hi I’m trying to animate nodes. If I’m dragging multiple nodes under a specific place, the nodes should all clump up together.
I overrode DraggingTool doMouseMove (I also super.doMouseMove()).
I loop through draggedParts then move all the nodes to the currentPart node.
After the nodes clump together I want the nodes to move together when I move my mouse.
This is a code snippet (the code is in a function which is called in doMouseMove) mainPartPoint is currentPart
When i use node.value.point the animation works perfectly but when i move the cursor, one node moves and the others don’t or sometimes all move , its very inconsistent.
When I use node.key.position or node.key.location, the animation is not smooth, the nodes don’t move smoothly towards the main point, they just appear under the main point. but once I start moving my mouse they all move as one (same behavior when I select multiple nodes on the canvas and move the mouse, they all move together).
Is there a way to have a smooth animation and move the nodes together after they’ve clumped up together.
I see you are using a different animation mechanism. Does it work better if you use the built-in animation provided by GoJS? GoJS Animation -- Northwoods Software
const draggedNodes = [];
let tempNode = null;
let mainNode: NodeData = null;
this.draggedParts.each((part) => {
tempNode = this.diagram.findNodeForData(part.key.data);
draggedNodes.push(tempNode);
if (tempNode.part === this.currentPart { mainNode = tempNode };
});
Looping through all nodes
var animation = new go.Animation();
animation.add(node, "position", node.position, new go.Point(mainNode.position.x, mainNode.position.y));
animation.start();
While dragging all the nodes (the node with the arrow being the mainNode) and when it reaches the X point I want the nodes to animate to the mainNodes position (maybe with an offset, but thats not the main concern). When I move the nodes after they clumped up, they dont move together.
So do you want all of the selected nodes to be dragged as they normally are, until the mouse gets to that red X point in the document? How close does the mouse need to get to that red X?
When the mouse has gotten to that red X, only then do the dragged nodes coalesce? And you want to animate that motion?
What happens when a mouse-up happens? Before reaching the red X? After reaching the red X? After reaching the red X and then moving away from that point before the mouse is released?
Do those dragged-to-red-X nodes remain “clumped” together, or are they still independent nodes that can be selected and move separately from each other?
Yes dragged normally, when they get to the X point the nodes not-on-the-cursor go to the node under the cursor. Basically the X point is a multistep, and we check if this.dropTarget is of type multistep.
yes and yes
So like I mentioned the X is a multistep (can think of it as a group), the dragged nodes will be part of the multistep when dropped on it . Before reaching a multistep the nodes act normally, as if they were moved from one point of the canvas to another. So when they are on the multistep, the nodes clump together, when they move away from the multistep without being released, they “unclump”.
When it moves away from the X they “unclump”. When they are dropped on the multistep they are individual nodes.
Hi Walter, thanks for replying.
Please see codepen https://codepen.io/Fezile-Mahlangu/pen/LYvJLZV
Is this the behavior you intended ? Delta just becomes gamma when i click on the green part, I’m confused.