Search code examples
javascriptvis.jsvis.js-network

Move the whole vis network when dragging a node


When I'm dragging the network, it moves great and change the position of the 'camera' as intended. But when I dragging a node it moves the node. Can I make it move the whole 'camera' as if I did not press the node?

I tried to use the 'dragging' event but I couldn't make it behave perfect as I wanted it to.


Solution

  • It seems, it's quite simple to implement, just remove selection on dragStart:

    var clearSelection = function(){
        network.unselectAll();
    };
    network.on('dragStart',clearSelection);
    

    Worked for me in this fiddle. (I've also tried network.on('selectNode',clearSelection); – may be useful for UX but doesn't do what you need)