feat(selection): disable pane movement when selection is dragged

This commit is contained in:
Christopher Möller
2021-11-18 16:53:41 +01:00
parent 2243b0a1f6
commit 004dcc6528
4 changed files with 8 additions and 4 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "react-flow-renderer", "name": "react-flow-renderer",
"version": "10.0.0-next.14", "version": "10.0.0-next.17",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "react-flow-renderer", "name": "react-flow-renderer",
"version": "10.0.0-next.14", "version": "10.0.0-next.17",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.15.4", "@babel/runtime": "^7.15.4",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "react-flow-renderer", "name": "react-flow-renderer",
"version": "10.0.0-next.14", "version": "10.0.0-next.17",
"engines": { "engines": {
"node": ">=12" "node": ">=12"
}, },
+4 -1
View File
@@ -5,6 +5,7 @@
import React, { useMemo, useCallback, useRef, MouseEvent } from 'react'; import React, { useMemo, useCallback, useRef, MouseEvent } from 'react';
import ReactDraggable, { DraggableData } from 'react-draggable'; import ReactDraggable, { DraggableData } from 'react-draggable';
import cc from 'classcat';
import { useStore } from '../../store'; import { useStore } from '../../store';
import { Node, ReactFlowState } from '../../types'; import { Node, ReactFlowState } from '../../types';
@@ -14,6 +15,7 @@ export interface NodesSelectionProps {
onSelectionDrag?: (event: MouseEvent, nodes: Node[]) => void; onSelectionDrag?: (event: MouseEvent, nodes: Node[]) => void;
onSelectionDragStop?: (event: MouseEvent, nodes: Node[]) => void; onSelectionDragStop?: (event: MouseEvent, nodes: Node[]) => void;
onSelectionContextMenu?: (event: MouseEvent, nodes: Node[]) => void; onSelectionContextMenu?: (event: MouseEvent, nodes: Node[]) => void;
noPanClassName?: string;
} }
// @TODO: work with nodeInternals instead of converting it to an array // @TODO: work with nodeInternals instead of converting it to an array
const selector = (s: ReactFlowState) => ({ const selector = (s: ReactFlowState) => ({
@@ -33,6 +35,7 @@ export default ({
onSelectionDrag, onSelectionDrag,
onSelectionDragStop, onSelectionDragStop,
onSelectionContextMenu, onSelectionContextMenu,
noPanClassName,
}: NodesSelectionProps) => { }: NodesSelectionProps) => {
const { transform, selectedNodesBbox, selectionActive, selectedNodes, snapToGrid, snapGrid, updateNodePosition } = const { transform, selectedNodesBbox, selectionActive, selectedNodes, snapToGrid, snapGrid, updateNodePosition } =
useStore(selector); useStore(selector);
@@ -105,7 +108,7 @@ export default ({
} }
return ( return (
<div className="react-flow__nodesselection react-flow__container" style={style}> <div className={cc(['react-flow__nodesselection', 'react-flow__container', noPanClassName])} style={style}>
<ReactDraggable <ReactDraggable
scale={tScale} scale={tScale}
grid={grid} grid={grid}
+1
View File
@@ -122,6 +122,7 @@ const FlowRenderer = ({
onSelectionDrag={onSelectionDrag} onSelectionDrag={onSelectionDrag}
onSelectionDragStop={onSelectionDragStop} onSelectionDragStop={onSelectionDragStop}
onSelectionContextMenu={onSelectionContextMenu} onSelectionContextMenu={onSelectionContextMenu}
noPanClassName={noPanClassName}
/> />
)} )}
<div <div