Skip to content

Commit efff553

Browse files
committed
feat: add edge hover
1 parent 19eba31 commit efff553

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/studio-graph/src/graph/hooks/useInit.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const useInit = () => {
2424
const height = containerRef.current.offsetHeight;
2525
let graph: ForceGraphInstance | ForceGraph3DInstance | null = null;
2626
engineStopped.current = false;
27-
console.log('init.......');
27+
2828
if (render === '2D') {
2929
graph = ForceGraph()(containerRef.current);
3030
graph
@@ -45,6 +45,9 @@ export const useInit = () => {
4545
})
4646
.onLinkClick(edge => {
4747
emitterRef.current?.emit('edge:click', edge);
48+
})
49+
.onLinkHover(edge => {
50+
emitterRef.current?.emit('edge:hover', edge);
4851
});
4952
}
5053
if (render === '3D') {
@@ -55,6 +58,9 @@ export const useInit = () => {
5558
.onNodeClick(node => {
5659
emitterRef.current?.emit('node:click', node);
5760
})
61+
.onNodeHover((node, prevNode) => {
62+
emitterRef.current?.emit('node:hover', { node, prevNode });
63+
})
5864
.onNodeRightClick((node, evt) => {
5965
emitterRef.current?.emit('node:contextmenu', { node, evt });
6066
})
@@ -63,6 +69,9 @@ export const useInit = () => {
6369
})
6470
.onLinkClick(edge => {
6571
emitterRef.current?.emit('edge:click', edge);
72+
})
73+
.onLinkHover((edge, prevEdge) => {
74+
emitterRef.current?.emit('edge:hover', { edge, prevEdge });
6675
});
6776
}
6877

packages/studio-graph/src/graph/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type EventType =
99
| 'node:hover'
1010
| 'canvas:click'
1111
| 'edge:click'
12+
| 'edge:hover'
1213
| 'combo:click';
1314

1415
export type Emitter = EEmitter<Record<EventType, unknown>>;

0 commit comments

Comments
 (0)