Skip to content

Commit

Permalink
Neighbor expansion (#86)
Browse files Browse the repository at this point in the history
* Expand nodes on double click

* Fix #84

* Enable dynamic re-layout on drag (not very smooth)

* Run linters

---------

Co-authored-by: Lint Bot <[email protected]>
  • Loading branch information
mewim and mewim authored Feb 22, 2024
1 parent a8b7dc6 commit c81d2cd
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 112 deletions.
53 changes: 0 additions & 53 deletions src/components/SchemaView/SchemaViewMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -865,59 +865,6 @@ export default {
reloadSchema() {
this.$emit("reloadSchema");
},
registerAddEdgeBehavior() {
if (window.g6AddEdgeBehaviorRegistered) {
return;
}
G6.registerBehavior('click-add-edge', {
getEvents() {
return {
'node:click': 'onClick',
mousemove: 'onMousemove',
'edge:click': 'onEdgeClick',
};
},
onClick(ev) {
const node = ev.item;
const graph = this.graph;
const point = { x: ev.x, y: ev.y };
const model = node.getModel();
if (this.addingEdge && this.edge) {
graph.updateItem(this.edge, {
target: model.id,
});
this.edge = null;
this.addingEdge = false;
} else {
this.edge = graph.addItem('edge', {
source: model.id,
target: point,
});
this.addingEdge = true;
}
},
onMousemove(ev) {
const point = { x: ev.x, y: ev.y };
if (this.addingEdge && this.edge) {
this.graph.updateItem(this.edge, {
target: point,
});
}
},
onEdgeClick(ev) {
const graph = this.graph;
const currentEdge = ev.item;
if (this.addingEdge && this.edge == currentEdge) {
graph.removeItem(this.edge);
this.edge = null;
this.addingEdge = false;
}
},
});
window.g6AddEdgeBehaviorRegistered = true;
},
},
};
</script>
Expand Down
Loading

0 comments on commit c81d2cd

Please sign in to comment.