Skip to content

Database diagrams editor that allows you to visualize and design your DB with a single query.

fix(canvas): fix auto zoom on diagram load (#395)

Guy Ben-Aharon492c9324d27b
diff --git a/src/pages/editor-page/canvas/canvas.tsx b/src/pages/editor-page/canvas/canvas.tsx
index 4f6dba0b..153917ab 100644
--- a/src/pages/editor-page/canvas/canvas.tsx
+++ b/src/pages/editor-page/canvas/canvas.tsx
@@ -166,7 +166,13 @@ export const Canvas: React.FC<CanvasProps> = ({ initialTables, readonly }) => {
useEffect(() => {
if (!isInitialLoadingNodes) {
- setTimeout(() => fitView({ maxZoom: 1, duration: 0 }), 0);
+ debounce(() => {
+ fitView({
+ duration: 200,
+ padding: 0.1,
+ maxZoom: 0.8,
+ });
+ }, 500)();
}
}, [isInitialLoadingNodes, fitView]);