Avoid stiky move on mouse leave

This commit is contained in:
Jeremie Pardou-Piquemal 2020-07-02 22:47:55 +02:00 committed by Jérémie Pardou-Piquemal
parent c4c88880c8
commit d1ca731928

View file

@ -92,12 +92,19 @@ const PanZoomRotate = ({ children }) => {
} }
}; };
const onMouseUp = (e) => { const onMouseUp = React.useCallback((e) => {
if (e.button === 1 || e.altKey) { if (e.button === 1 || e.altKey) {
stateRef.current.moving = false; stateRef.current.moving = false;
wrapperRef.current.style.cursor = "auto"; wrapperRef.current.style.cursor = "auto";
} }
}; }, []);
React.useEffect(() => {
document.addEventListener("mouseup", onMouseUp);
return () => {
document.removeEventListener("mouseup", onMouseUp);
};
}, [onMouseUp]);
return ( return (
<div <div