First, on your explicit question: what does the call()
method do?
In d3, call
is just a convenience function to turn other functions inside out. Doing
node.call( force.drag );
Is actually just the same as doing
force.drag( node );
The only difference is that the call
method on a selection always returns the selection so you can chain other methods to it.
So now your question is, what does the force.drag( selection )
do? It creates the event listeners that handle the mouse and touch events for the drag behaviour. Those event listeners update the position of the node data object, but they also restart the force layout.
If you don't want the default force-layout drag behaviour, just don't call the force.drag
method on your selection.
As far as being able to customize the drag behaviour so that it doesn't restart the force layout, it doesn't look like you can do it with force.drag
(not without changing the source code, anyway). However, you can access most of the drag-related functionality by creating your own drag behaviour object and binding it to the nodes.
Then, in your drag event handler you would update the x and y positions of the node data object, and redraw the node and any links attached to it. If your graph isn't too big, you can do this by re-calling your tick
function to redraw all the elements to match their data; if your graph is big, you might want to store references to the actual elements in the data objects so you can quickly find the correct links.
Some examples on using drag behaviours (without force layout) to get you started: