feat(nodes): add selection

This commit is contained in:
moklick
2019-07-16 15:41:31 +02:00
parent d65121d197
commit a66f707f11
7 changed files with 289 additions and 39 deletions
+3 -2
View File
@@ -1,4 +1,5 @@
import { zoomIdentity } from 'd3-zoom';
import { getBoundingBox } from '../graph-utils';
export const SET_EDGES = 'SET_EDGES';
@@ -56,9 +57,9 @@ export const reducer = (state, action) => {
const boundsCenterX = bounds.x + (bounds.width / 2);
const boundsCenterY = bounds.y + (bounds.height / 2);
const translate = [(state.width / 2) - (boundsCenterX * k), (state.height / 2) - (boundsCenterY * k)];
const initialTransform = zoomIdentity.translate(translate[0], translate[1]).scale(k);
const fittedTransform = zoomIdentity.translate(translate[0], translate[1]).scale(k);
state.d3Selection.call(state.d3Zoom.transform, initialTransform);
state.d3Selection.call(state.d3Zoom.transform, fittedTransform);
return state;
}