feat(interaction): add zoomOnScroll property closes #331

This commit is contained in:
moklick
2020-07-14 13:28:59 +02:00
parent 0593db289a
commit 65764fbefb
5 changed files with 29 additions and 3 deletions
+7 -2
View File
@@ -6,10 +6,11 @@ import { useStoreState, useStoreActions } from '../store/hooks';
interface UseD3ZoomParams {
zoomPane: MutableRefObject<Element | null>;
selectionKeyPressed: boolean;
zoomOnScroll: boolean;
onMove?: () => void;
}
export default ({ zoomPane, onMove, selectionKeyPressed }: UseD3ZoomParams): void => {
export default ({ zoomPane, onMove, zoomOnScroll, selectionKeyPressed }: UseD3ZoomParams): void => {
const d3Zoom = useStoreState((s) => s.d3Zoom);
const initD3 = useStoreActions((actions) => actions.initD3);
@@ -31,6 +32,10 @@ export default ({ zoomPane, onMove, selectionKeyPressed }: UseD3ZoomParams): voi
return;
}
if (!zoomOnScroll && event.sourceEvent.type === 'wheel') {
return;
}
updateTransform(event.transform);
if (onMove) {
@@ -39,5 +44,5 @@ export default ({ zoomPane, onMove, selectionKeyPressed }: UseD3ZoomParams): voi
});
}
}
}, [selectionKeyPressed, d3Zoom]);
}, [selectionKeyPressed, zoomOnScroll, d3Zoom]);
};