feat(nodesselection): zoom- and scalable nodes selection

This commit is contained in:
moklick
2019-07-24 11:37:40 +02:00
parent 1ba6e7b26b
commit ac8ac49d1d
7 changed files with 161 additions and 58 deletions
+29
View File
@@ -0,0 +1,29 @@
import React, { useContext } from 'react';
import { GraphContext } from '../GraphContext';
import { setNodesSelection } from '../state/actions';
export default () => {
const graphContext = useContext(GraphContext);
const { state, dispatch } = graphContext;
return (
<div
className="react-graph__nodesselection"
style={{
transform: `translate(${state.transform[0]}px,${state.transform[1]}px) scale(${state.transform[2]})`
}}
onClick={() => dispatch(setNodesSelection({ isActive: false }))}
>
<div
className="react-graph__nodesselection-rect"
style={{
width: state.selectedNodesBbox.width,
height: state.selectedNodesBbox.height,
top: state.selectedNodesBbox.y,
left: state.selectedNodesBbox.x
}}
/>
</div>
);
};