d3 click and drag event nesting

后端 未结 2 433
無奈伤痛
無奈伤痛 2020-12-08 17:45

I am nesting a lot of elements inside of a g element like so:


    
    
    ...

         


        
2条回答
  •  暖寄归人
    2020-12-08 18:33

    I have a similar sort of issue (http://jsfiddle.net/j8RZN/1/), except the suggested workaround does not seem to be helping.

    userBox.data([userBox]).call(d3.behavior.drag() //makes the box to move
    //titleBox.data([userBox]).call(d3.behavior.drag()  //does not make the box move
    .on("dragstart", function() {})
    .on("drag", function(d, i) {
    console.log('box being dragged');
    d.attr("transform", "translate(" + (d3.event.x) +  "," + (d3.event.y) + ")");
    })
    .on("dragend", function() {}));
    
    circleDrag.call(d3.behavior.drag()
    .on("dragstart", function() {})
    .on("drag", function(d, i) {
     d3.event.sourceEvent.stopPropagation();
     console.log('small rectangle being dragged');
    })
    .on("dragend", function() {}));
    

提交回复
热议问题