@@ -17,7 +17,6 @@ import {
1717 EdgeStyle ,
1818 StyleClass ,
1919 NodeGrouping ,
20- Popup ,
2120 Geo ,
2221 NodeGroupingProps ,
2322 useEvent ,
@@ -45,10 +44,6 @@ export default function App() {
4544 const [ graph , setGraph ] = useState < RawGraph > ( ) ;
4645 const [ loading , setLoading ] = useState ( true ) ;
4746
48- // UI states
49- const [ popupOpen , setPopupOpen ] = useState ( false ) ;
50- const [ clickedNode , setClickedNode ] = useState < OgmaNode > ( ) ;
51-
5247 // ogma instance and grouping references
5348 const ogmaInstanceRef = createRef < OgmaLib > ( ) ;
5449 const groupingRef = createRef < NodeGroupingTransformation < ND , ED > > ( ) ;
@@ -75,12 +70,6 @@ export default function App() {
7570 // UI layers
7671 const [ outlines , setOutlines ] = useState ( false ) ;
7772
78- const popupPosition = useCallback (
79- ( ) => ( clickedNode ? clickedNode . getPosition ( ) : null ) ,
80- [ clickedNode ]
81- ) ;
82- const onPopupClose = useCallback ( ( ) => setPopupOpen ( false ) , [ ] ) ;
83-
8473 // load the graph
8574 useEffect ( ( ) => {
8675 setLoading ( true ) ;
@@ -92,20 +81,14 @@ export default function App() {
9281 } ) ;
9382 } , [ ] ) ;
9483
95- const onClick = useEvent ( "click" , ( { target } ) => {
96- if ( target && target . isNode ) {
97- setClickedNode ( target ) ;
98- setPopupOpen ( true ) ;
99- }
100- } ) ;
101-
10284 const onAddNodes = useEvent ( "addNodes" , ( ) => {
10385 if ( ! ogmaInstanceRef . current ) return ;
10486 ogmaInstanceRef . current . view . locateGraph ( { duration : 250 , padding : 50 } ) ;
10587 } ) ;
10688
10789 const onReady = useCallback ( ( instance : OgmaLib < ND , ED > ) => {
10890 ogmaInstanceRef . current = instance ;
91+ window . ogma = instance ;
10992 } , [ ] ) ;
11093
11194 const addNode = useCallback ( ( ) => {
@@ -140,7 +123,6 @@ export default function App() {
140123 < Ogma
141124 ref = { ogmaInstanceRef }
142125 graph = { graph }
143- onClick = { onClick }
144126 onAddNodes = { onAddNodes }
145127 onReady = { onReady }
146128 theme = { morningBreeze as Theme < ND , ED > }
@@ -194,16 +176,6 @@ export default function App() {
194176 nodeGenerator = { groupingOptions . nodeGenerator }
195177 />
196178
197- { /* context-aware UI */ }
198- < Popup
199- position = { popupPosition }
200- onClose = { onPopupClose }
201- isOpen = { ! ! clickedNode && popupOpen }
202- >
203- { ! ! clickedNode && (
204- < div className = "content" > { `Node ${ clickedNode . getId ( ) } :` } </ div >
205- ) }
206- </ Popup >
207179 < Tooltip
208180 eventName = "nodeRightclick"
209181 placement = "right"
0 commit comments