feat(interaction): add zoomOnScroll property closes #331
This commit is contained in:
@@ -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]);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user