example(interactions): toggle on element click

This commit is contained in:
Nate Amack
2020-08-18 11:13:31 -06:00
parent 34473166cb
commit a803821a3e
2 changed files with 29 additions and 2 deletions
+14 -1
View File
@@ -28,6 +28,7 @@ const InteractionFlow = () => {
const [zoomOnDoubleClick, setZoomOnDoubleClick] = useState(false);
const [paneMoveable, setPaneMoveable] = useState(true);
const [captureZoomClick, setCaptureZoomClick] = useState(false);
const [captureElementClick, setCaptureElementClick] = useState(false);
return (
<ReactFlow
@@ -38,7 +39,7 @@ const InteractionFlow = () => {
zoomOnScroll={zoomOnScroll}
zoomOnDoubleClick={zoomOnDoubleClick}
onConnect={onConnect}
onElementClick={onElementClick}
onElementClick={captureElementClick ? onElementClick : undefined}
onNodeDragStart={onNodeDragStart}
onNodeDragStop={onNodeDragStop}
paneMoveable={paneMoveable}
@@ -133,6 +134,18 @@ const InteractionFlow = () => {
/>
</label>
</div>
<div>
<label htmlFor="captureelementclick">
capture element click
<input
id="captureelementclick"
type="checkbox"
checked={captureElementClick}
onChange={(event) => setCaptureElementClick(event.target.checked)}
className="react-flow__captureelementclick"
/>
</label>
</div>
</div>
</ReactFlow>
);