Fixes Workflow visualizer toolbar disappearing.

This commit is contained in:
Alex Corey 2022-03-03 17:56:14 -05:00
parent 1679102204
commit efb01f3c36

View File

@ -181,6 +181,19 @@ function VisualizerGraph({ readOnly }) {
};
const zoomRef = d3.zoom().scaleExtent([0.1, 2]).on('zoom', zoom);
// This useEffect prevents the Visualizer toolbar from going off the screen
// as the user zooms in too much. It effectively makes the toolbarr a sticky header
// The user can still zoom in/out but there are limited to the degree they can do so
// by the zoomExtent above.
useEffect(() => {
const cancelWheel = (event) => event.preventDefault();
document.body.addEventListener('wheel', cancelWheel, { passive: false });
return () => {
document.body.removeEventListener('wheel', cancelWheel);
};
}, []);
// Initialize the zoom
useEffect(() => {