Skip to content

Commit

Permalink
[FIX] fixed graph size behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Artkrygin committed Sep 7, 2021
1 parent 980c0ff commit 0687372
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/diagram/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export const Graph = ({
graph.resize(width, height);
};
resizeFn();
const resizeObserver = new ResizeObserver((entries) => {
resizeFn();
});
graph.selection.widget.collection.on('updated', (e) => {
const nodeIds = graph.selection.widget.collection.cells.map((c) => {
return { id: c.id, ...c.store.data.subject };
Expand All @@ -76,10 +79,12 @@ export const Graph = ({
});
graph.enableRubberband();
window.addEventListener('resize', resizeFn);
resizeObserver.observe(refWrap.current);
// dispose attached HTML objects
return () => {
graph.dispose();
window.removeEventListener('resize', resizeFn);
resizeObserver.disconnect();
};
}, []);

Expand Down Expand Up @@ -143,7 +148,6 @@ export const Graph = ({
Load More
</Button>*/}
<ZoomToolbar graph={graph} />

<div
id='container'
style={{ position: 'absolute', top: 0, left: 0 }}
Expand Down

0 comments on commit 0687372

Please sign in to comment.