bug fix: make sure we actually update event handlers when selection begins.
This commit is contained in:
@@ -39,6 +39,7 @@ const selector = (s: ReactFlowState) => ({
|
|||||||
d3Zoom: s.d3Zoom,
|
d3Zoom: s.d3Zoom,
|
||||||
d3Selection: s.d3Selection,
|
d3Selection: s.d3Selection,
|
||||||
d3ZoomHandler: s.d3ZoomHandler,
|
d3ZoomHandler: s.d3ZoomHandler,
|
||||||
|
userSelectionActive: s.userSelectionActive,
|
||||||
});
|
});
|
||||||
|
|
||||||
const ZoomPane = ({
|
const ZoomPane = ({
|
||||||
@@ -68,7 +69,7 @@ const ZoomPane = ({
|
|||||||
const isZoomingOrPanning = useRef(false);
|
const isZoomingOrPanning = useRef(false);
|
||||||
const zoomPane = useRef<HTMLDivElement>(null);
|
const zoomPane = useRef<HTMLDivElement>(null);
|
||||||
const prevTransform = useRef<Viewport>({ x: 0, y: 0, zoom: 0 });
|
const prevTransform = useRef<Viewport>({ x: 0, y: 0, zoom: 0 });
|
||||||
const { d3Zoom, d3Selection, d3ZoomHandler } = useStore(selector, shallow);
|
const { d3Zoom, d3Selection, d3ZoomHandler, userSelectionActive } = useStore(selector, shallow);
|
||||||
const zoomActivationKeyPressed = useKeyPress(zoomActivationKeyCode);
|
const zoomActivationKeyPressed = useKeyPress(zoomActivationKeyCode);
|
||||||
|
|
||||||
useResizeHandler(zoomPane);
|
useResizeHandler(zoomPane);
|
||||||
@@ -155,9 +156,9 @@ const ZoomPane = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (d3Zoom) {
|
if (d3Zoom) {
|
||||||
if (store.getState().userSelectionActive && !isZoomingOrPanning.current) {
|
if (userSelectionActive && !isZoomingOrPanning.current) {
|
||||||
d3Zoom.on('zoom', null);
|
d3Zoom.on('zoom', null);
|
||||||
} else if (!store.getState().userSelectionActive) {
|
} else if (!userSelectionActive) {
|
||||||
d3Zoom.on('zoom', (event: D3ZoomEvent<HTMLDivElement, any>) => {
|
d3Zoom.on('zoom', (event: D3ZoomEvent<HTMLDivElement, any>) => {
|
||||||
const { onViewportChange } = store.getState();
|
const { onViewportChange } = store.getState();
|
||||||
|
|
||||||
@@ -172,7 +173,7 @@ const ZoomPane = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [store, d3Zoom, onMove]);
|
}, [userSelectionActive, d3Zoom, onMove]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (d3Zoom) {
|
if (d3Zoom) {
|
||||||
@@ -242,7 +243,7 @@ const ZoomPane = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// during a selection we prevent all other interactions
|
// during a selection we prevent all other interactions
|
||||||
if (store.getState().userSelectionActive) {
|
if (userSelectionActive) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +281,7 @@ const ZoomPane = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
store,
|
userSelectionActive,
|
||||||
d3Zoom,
|
d3Zoom,
|
||||||
zoomOnScroll,
|
zoomOnScroll,
|
||||||
zoomOnPinch,
|
zoomOnPinch,
|
||||||
|
|||||||
Reference in New Issue
Block a user