Neilos / bihisankey

A d3 javascript library/plugin for drawing bi-directional hierarchical sankey diagrams
68 stars 24 forks source link

showHideChildren in chremo not working #11

Closed ChenOct closed 7 years ago

ChenOct commented 7 years ago

Hey, At the new version of chrome (Version 58. (64-bit)), the function double click (to show and hide children) - not working anymore. At Version 57. (64-bit) it's working great. In explorer it's working great too. Why does it's happend? Thanks.

aflcode commented 7 years ago

Same issue in chrome Version 58.0.3029.110. If anybody has a fix, please reply I am interested.

ChenOct commented 7 years ago

I solve the problem. This append because when you double click - two event are called : 'dblclick' and 'dragstart', and 'dragstart' event overrides the 'dblclick' event. To fix it I change the code from:

node.filter(function (d) {
    return d.children.length;
})
.on("dblclick", showHideChildren);

// allow nodes to be dragged to new positions
node.call(d3.behavior.drag()
 .origin(function (d) {
      return d;
 })
 .on("dragstart", function () {
      this.parentNode.appendChild(this);
 })
 .on("drag", dragmove));

to be:

node.filter(function (d) {
    return d.children.length;
})

// allow nodes to be dragged to new positions
var drag = d3.layout.force().drag()
 .on("drag", dragmove)

node.on("dblclick", showHideChildren)
 .call(drag);
aflcode commented 7 years ago

@ChenOct - Thanks that works great! Thanks for posting the fix.