|
@@ -41,6 +41,7 @@ const StyledEditorWrapper = styled.div<{ isWidget: boolean }>`
|
|
`;
|
|
`;
|
|
|
|
|
|
const GraphComponent = ({ isWidget, openModal, setSelectedNode }: LayoutProps) => {
|
|
const GraphComponent = ({ isWidget, openModal, setSelectedNode }: LayoutProps) => {
|
|
|
|
+ const [minScale, setMinScale] = React.useState(0.3);
|
|
const setGraphValue = useGraph(state => state.setGraphValue);
|
|
const setGraphValue = useGraph(state => state.setGraphValue);
|
|
const setConfig = useConfig(state => state.setConfig);
|
|
const setConfig = useConfig(state => state.setConfig);
|
|
const loading = useGraph(state => state.loading);
|
|
const loading = useGraph(state => state.loading);
|
|
@@ -71,7 +72,11 @@ 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) {
|
|
|
|
+ const areaSize = layout.width * layout.height;
|
|
|
|
+
|
|
|
|
+ setMinScale((1_000_000 * 0.5) / areaSize);
|
|
setSize({ width: layout.width + 400, height: layout.height + 400 });
|
|
setSize({ width: layout.width + 400, height: layout.height + 400 });
|
|
|
|
+
|
|
requestAnimationFrame(() => {
|
|
requestAnimationFrame(() => {
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
setGraphValue("loading", false);
|
|
setGraphValue("loading", false);
|
|
@@ -94,9 +99,9 @@ const GraphComponent = ({ isWidget, openModal, setSelectedNode }: LayoutProps) =
|
|
{loading && <Loading message="Painting graph..." />}
|
|
{loading && <Loading message="Painting graph..." />}
|
|
<TransformWrapper
|
|
<TransformWrapper
|
|
maxScale={2}
|
|
maxScale={2}
|
|
- minScale={0.25}
|
|
|
|
- initialScale={0.7}
|
|
|
|
- wheel={{ step: 0.05 }}
|
|
|
|
|
|
+ minScale={minScale}
|
|
|
|
+ initialScale={0.4}
|
|
|
|
+ wheel={{ step: 0.08 }}
|
|
zoomAnimation={{ animationType: "linear" }}
|
|
zoomAnimation={{ animationType: "linear" }}
|
|
doubleClick={{ disabled: true }}
|
|
doubleClick={{ disabled: true }}
|
|
onInit={onInit}
|
|
onInit={onInit}
|
|
@@ -114,6 +119,7 @@ const GraphComponent = ({ isWidget, openModal, setSelectedNode }: LayoutProps) =
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
<Canvas
|
|
<Canvas
|
|
|
|
+ className="jsoncrack-canvas"
|
|
nodes={nodes}
|
|
nodes={nodes}
|
|
edges={edges}
|
|
edges={edges}
|
|
maxWidth={size.width}
|
|
maxWidth={size.width}
|