From d6a6eb82d804fc1e7e2d1092ff5cf083fd56277e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christopher=20Mo=CC=88ller?= Date: Thu, 29 Oct 2020 17:57:31 +0100 Subject: [PATCH] refactor pan/zoom behaviour, implement pan on scroll #359, edit interaction example --- example/src/Interaction/index.js | 32 ++++++++++---- src/container/FlowRenderer/index.tsx | 4 ++ src/container/GraphView/index.tsx | 4 ++ src/container/ReactFlow/index.tsx | 3 ++ src/hooks/useD3Zoom.ts | 65 ++++++++++++++++++---------- src/store/index.ts | 21 +++++++++ 6 files changed, 96 insertions(+), 33 deletions(-) diff --git a/example/src/Interaction/index.js b/example/src/Interaction/index.js index af7aafd9..ba2f11fa 100644 --- a/example/src/Interaction/index.js +++ b/example/src/Interaction/index.js @@ -26,6 +26,7 @@ const InteractionFlow = () => { const [isDraggable, setIsDraggable] = useState(false); const [isConnectable, setIsConnectable] = useState(false); const [zoomOnScroll, setZoomOnScroll] = useState(false); + const [panOnScroll, setPanOnScroll] = useState(true); const [zoomOnDoubleClick, setZoomOnDoubleClick] = useState(false); const [paneMoveable, setPaneMoveable] = useState(true); const [captureZoomClick, setCaptureZoomClick] = useState(false); @@ -39,6 +40,7 @@ const InteractionFlow = () => { nodesConnectable={isConnectable} nodesDraggable={isDraggable} zoomOnScroll={zoomOnScroll} + panOnScroll={panOnScroll} zoomOnDoubleClick={zoomOnDoubleClick} onConnect={onConnect} onElementClick={captureElementClick ? onElementClick : undefined} @@ -55,7 +57,7 @@ const InteractionFlow = () => {
+
+ +