|
@@ -41,9 +41,8 @@ const StyledEditorWrapper = styled.div<{ isWidget: boolean }>`
|
|
`;
|
|
`;
|
|
|
|
|
|
const GraphComponent = ({ isWidget, openModal, setSelectedNode }: LayoutProps) => {
|
|
const GraphComponent = ({ isWidget, openModal, setSelectedNode }: LayoutProps) => {
|
|
- const setConfig = useConfig(state => state.setConfig);
|
|
|
|
- const maxZoom = useConfig(state => state.maxZoom);
|
|
|
|
const setGraphValue = useGraph(state => state.setGraphValue);
|
|
const setGraphValue = useGraph(state => state.setGraphValue);
|
|
|
|
+ const setConfig = useConfig(state => state.setConfig);
|
|
const loading = useGraph(state => state.loading);
|
|
const loading = useGraph(state => state.loading);
|
|
const layout = useConfig(state => state.layout);
|
|
const layout = useConfig(state => state.layout);
|
|
const nodes = useGraph(state => state.nodes);
|
|
const nodes = useGraph(state => state.nodes);
|
|
@@ -72,20 +71,6 @@ const GraphComponent = ({ isWidget, openModal, setSelectedNode }: LayoutProps) =
|
|
const onLayoutChange = React.useCallback(
|
|
const onLayoutChange = React.useCallback(
|
|
(layout: ElkRoot) => {
|
|
(layout: ElkRoot) => {
|
|
if (layout.width && layout.height) {
|
|
if (layout.width && layout.height) {
|
|
- let newHeight = 0;
|
|
|
|
- let newWidth = 0;
|
|
|
|
-
|
|
|
|
- layout?.children?.forEach(node => {
|
|
|
|
- if (node.y + node.height > newHeight) newHeight = node.y + node.height;
|
|
|
|
- if (node.x + node.width > newWidth) newWidth = node.x + node.width;
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- if (layout === "LEFT" || layout === "RIGHT") {
|
|
|
|
- setConfig("maxZoom", (1380 * 0.6) / newHeight);
|
|
|
|
- } else {
|
|
|
|
- setConfig("maxZoom", (1380 * 0.6) / newWidth);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
setSize({ width: layout.width + 400, height: layout.height + 400 });
|
|
setSize({ width: layout.width + 400, height: layout.height + 400 });
|
|
requestAnimationFrame(() => {
|
|
requestAnimationFrame(() => {
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
@@ -94,7 +79,7 @@ const GraphComponent = ({ isWidget, openModal, setSelectedNode }: LayoutProps) =
|
|
});
|
|
});
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- [setConfig, setGraphValue]
|
|
|
|
|
|
+ [setGraphValue]
|
|
);
|
|
);
|
|
|
|
|
|
const onCanvasClick = React.useCallback(() => {
|
|
const onCanvasClick = React.useCallback(() => {
|
|
@@ -109,7 +94,7 @@ const GraphComponent = ({ isWidget, openModal, setSelectedNode }: LayoutProps) =
|
|
{loading && <Loading message="Painting graph..." />}
|
|
{loading && <Loading message="Painting graph..." />}
|
|
<TransformWrapper
|
|
<TransformWrapper
|
|
maxScale={2}
|
|
maxScale={2}
|
|
- minScale={maxZoom}
|
|
|
|
|
|
+ minScale={0.25}
|
|
initialScale={0.7}
|
|
initialScale={0.7}
|
|
wheel={{ step: 0.05 }}
|
|
wheel={{ step: 0.05 }}
|
|
zoomAnimation={{ animationType: "linear" }}
|
|
zoomAnimation={{ animationType: "linear" }}
|