Search code examples
javascriptd3.jsdraggabledrag

Drag issue in d3.js v5.4.0


I am trying to implement this example using the d3.js v5.4.0.

But as you can see here and here:enter image description here

The previous image of the node does not become deleted after the drag even though there is no error thrown.

I debugged the drag code stepping through the lines and was not able to find a reason for this. Will appreciate any help provided.

I thinks that the problem may be somewhere over here:

thisGraph.drag = d3.drag()
            .subject(function(d){
                return {x: d.x, y: d.y};
            })
            .on("drag", function(args){
                thisGraph.state.justDragged = true;
                thisGraph.dragmove.call(thisGraph, args);
            })
            .on("end", function() {
                // todo check if edge-mode is selected
            });

Solution

  • Are you using Canvas? You need to run

    context.clearRect(0, 0, canvasWidth, canvasHeight);
    

    each time it renders