Skip to content

Commit

Permalink
feat(#65): add custom click event for marriage nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMartiniMo committed Feb 7, 2020
1 parent 112a375 commit b4111d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,22 @@ class TreeBuilder {
if (d.data.hidden) {
return;
}
opts.callbacks.nodeClick(d.data.name, d.data.extra, d.data.id);
if (d.data.isMarriage) {
opts.callbacks.marriageClick(d.data.extra, d.data.id)
} else {
opts.callbacks.nodeClick(d.data.name, d.data.extra, d.data.id)
}
})
.on('contextmenu', function(d)  {
if (d.data.hidden) {
return;
}
d3.event.preventDefault();
opts.callbacks.nodeRightClick(d.data.name, d.data.extra, d.data.id);
if (d.data.isMarriage) {
opts.callbacks.marriageRightClick(d.data.extra, d.data.id)
} else {
opts.callbacks.nodeRightClick(d.data.name, d.data.extra, d.data.id)
}
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/dtree.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const dTree = {
callbacks: {
nodeClick: function(name, extra, id) {},
nodeRightClick: function(name, extra, id) {},
marriageClick: function(extra, id) {},
marriageRightClick: function(extra, id) {},
nodeHeightSeperation: function(nodeWidth, nodeMaxHeight) {
return TreeBuilder._nodeHeightSeperation(nodeWidth, nodeMaxHeight);
},
Expand Down

0 comments on commit b4111d6

Please sign in to comment.