react-phylogeny-tree-gl
Version:
React integration of phylocanvas.gl. Component and hook for phylogenetic tree visualistion.
22 lines • 823 B
JavaScript
import { getNodeLeafOffspringsIDs } from '../utils';
export function onClickHighlightOffsprings(tree, decorate) {
decorate('selectNode', (delegate, args) => {
const [nodeOrId, append] = args;
const node = nodeOrId ? tree.findNodeById(nodeOrId) : null;
if (node && !node.isLeaf) {
const ids = getNodeLeafOffspringsIDs(node);
if (append) {
const newItems = new Set(tree.props.selectedIds);
for (const id of ids) {
newItems.add(id);
}
this.setProps({ selectedIds: Array.from(newItems) });
}
else {
this.setProps({ selectedIds: ids });
}
}
delegate(...args);
});
}
//# sourceMappingURL=onClickHighlightOffsprings.js.map