Currently, I am utilizing Cytoscape JS to develop a web browser-based tool for manipulating graphs. I am encountering an issue related to listening to the drag event of multiple selected nodes.
I have successfully listened to the 'drag' event of nodes using the provided code snippet:
cy.on('drag', 'node', function (e) {
let draggedNode = e.target
...
}
However, the problem arises when I attempt to drag several nodes simultaneously, as the event is triggered individually for each selected node.
My objective is to specifically listen to the drag event of a single node when multiple nodes are selected, focusing only on the node directly being dragged by the user. This means that when dragging multiple selected nodes, the event should only be triggered for the node directly under the user's cursor or finger.
This requirement is akin to the 'grabon', 'freeon' and 'dragfreeon' events available in CytoscapeJS. Unfortunately, there is no 'dragon' event that caters to this specific scenario. I do not wish to listen to drag events for all currently selected nodes, but only for the one currently under the cursor or finger.
I have attempted to extract the cursor position from the passed 'e' parameter in order to perform a test to determine if the cursor is positioned over the triggering node. However, I discovered that the 'position' and 'renderedPosition' attributes were both undefined, thereby hindering my ability to conduct this test.
So, if anyone has insight on how to implement this functionality in JavaScript, I would greatly appreciate your help. Thank you.