Skip to content

Commit

Permalink
Simplify ReactFlowWrapper initialization and fit view logic
Browse files Browse the repository at this point in the history
- Remove custom onInit handler
- Use predefined fitViewOptions
- Clean up unnecessary initialization code
  • Loading branch information
georgi committed Feb 3, 2025
1 parent e910e45 commit 81ceb05
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions web/src/components/node/ReactFlowWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,8 @@ const ReactFlowWrapper: React.FC<ReactFlowWrapperProps> = ({
}, [reactFlowInstance]);

const fitScreen = useCallback(() => {
const fitOptions: FitViewOptions = {
maxZoom: 8,
minZoom: 0.01,
padding: 0.6
};

if (reactFlowInstance) {
reactFlowInstance.fitView(fitOptions);
reactFlowInstance.fitView(fitViewOptions);
setShouldFitToScreen(false);
}
}, [reactFlowInstance, setShouldFitToScreen]);
Expand All @@ -351,13 +345,6 @@ const ReactFlowWrapper: React.FC<ReactFlowWrapperProps> = ({
}
}, [fitScreen, shouldFitToScreen]);

// INIT
const handleOnInit = useCallback(() => {
setTimeout(() => {
fitScreen();
}, 10);
}, [fitScreen]);

if (loadingState?.isLoading) {
return (
<div className="loading-overlay">
Expand Down Expand Up @@ -438,7 +425,6 @@ const ReactFlowWrapper: React.FC<ReactFlowWrapperProps> = ({
onMoveStart={handleOnMoveStart}
onDoubleClick={handleDoubleClick}
proOptions={proOptions}
onInit={handleOnInit}
panActivationKeyCode=""
// onSelectionChange={onSelectionChange}
// edgeTypes={edgeTypes}
Expand Down

0 comments on commit 81ceb05

Please sign in to comment.