Browse Source

fix canvas center

AykutSarac 3 years ago
parent
commit
32c95620c3
1 changed files with 5 additions and 7 deletions
  1. 5 7
      src/containers/LiveEditor/index.tsx

+ 5 - 7
src/containers/LiveEditor/index.tsx

@@ -5,7 +5,7 @@ import {
   TransformComponent,
   TransformComponent,
   ReactZoomPanPinchRef,
   ReactZoomPanPinchRef,
 } from "react-zoom-pan-pinch";
 } from "react-zoom-pan-pinch";
-import { Canvas, CanvasPosition } from "reaflow";
+import { Canvas, CanvasPosition, CanvasRef } from "reaflow";
 
 
 import { getEdgeNodes } from "./helpers";
 import { getEdgeNodes } from "./helpers";
 import { CustomNode } from "../../components/CustomNode";
 import { CustomNode } from "../../components/CustomNode";
@@ -45,8 +45,8 @@ export const LiveEditor: React.FC = React.memo(function LiveEditor() {
     edges: [],
     edges: [],
   });
   });
   const [size, setSize] = React.useState({
   const [size, setSize] = React.useState({
-    width: 20000,
-    height: 20000,
+    width: 2000,
+    height: 2000,
   });
   });
 
 
   React.useEffect(() => {
   React.useEffect(() => {
@@ -87,12 +87,10 @@ export const LiveEditor: React.FC = React.memo(function LiveEditor() {
               nodes={data.nodes}
               nodes={data.nodes}
               node={(props) => <CustomNode {...props} />}
               node={(props) => <CustomNode {...props} />}
               edges={data.edges}
               edges={data.edges}
-              maxWidth={size.width + 1000}
-              maxHeight={size.height + 1000}
+              maxWidth={size.width}
+              maxHeight={size.height}
               zoomable={false}
               zoomable={false}
-              fit={true}
               direction={settings.layout}
               direction={settings.layout}
-              defaultPosition={CanvasPosition.CENTER}
               readonly
               readonly
               key={settings.layout}
               key={settings.layout}
               onCanvasClick={onCanvasClick}
               onCanvasClick={onCanvasClick}