fix zoom behaviour while selection key is pressed

This commit is contained in:
Christopher Möller
2020-11-02 13:19:04 +01:00
6 changed files with 201 additions and 181 deletions
+13 -10
View File
@@ -55,7 +55,6 @@ const ZoomPane = ({
const initD3 = useStoreActions((actions) => actions.initD3);
const updateTransform = useStoreActions((actions) => actions.updateTransform);
const updateTransformDelta = useStoreActions((actions) => actions.updateTransformDelta);
useResizeHandler(zoomPane);
@@ -83,16 +82,20 @@ const ZoomPane = ({
useEffect(() => {
if (d3Zoom) {
d3Zoom.on('zoom', (event: any) => {
updateTransform(event.transform);
if (selectionKeyPressed) {
d3Zoom.on('zoom', null);
} else {
d3Zoom.on('zoom', (event: any) => {
updateTransform(event.transform);
if (onMove) {
const flowTransform = eventToFlowTransform(event.transform);
onMove(flowTransform);
}
});
if (onMove) {
const flowTransform = eventToFlowTransform(event.transform);
onMove(flowTransform);
}
});
}
}
}, [selectionKeyPressed, panOnScroll, d3Zoom, updateTransform, updateTransformDelta, onMove]);
}, [selectionKeyPressed, d3Zoom, updateTransform, onMove]);
useEffect(() => {
if (d3Zoom) {
@@ -137,7 +140,7 @@ const ZoomPane = ({
}
// during a selection we prevent all other interactions
if (elementsSelectable && selectionKeyPressed) {
if (selectionKeyPressed) {
return false;
}