fix(core): the pitch zooming function incorrectly zooms the toolbar (#5456)
Co-authored-by: LongYinan <lynweklm@gmail.com>
This commit is contained in:
@@ -96,11 +96,15 @@ export const useZoomControls = ({
|
|||||||
[dragEndImpl]
|
[dragEndImpl]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleMouseUp = useCallback(() => {
|
const handleMouseUp = useCallback(
|
||||||
|
(evt: MouseEvent) => {
|
||||||
|
evt.preventDefault();
|
||||||
if (isDragging) {
|
if (isDragging) {
|
||||||
dragEndImpl();
|
dragEndImpl();
|
||||||
}
|
}
|
||||||
}, [isDragging, dragEndImpl]);
|
},
|
||||||
|
[isDragging, dragEndImpl]
|
||||||
|
);
|
||||||
|
|
||||||
const checkZoomSize = useCallback(() => {
|
const checkZoomSize = useCallback(() => {
|
||||||
const { current: zoomArea } = zoomRef;
|
const { current: zoomArea } = zoomRef;
|
||||||
@@ -183,15 +187,17 @@ export const useZoomControls = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleScroll = (event: WheelEvent) => {
|
const handleScroll = (event: WheelEvent) => {
|
||||||
|
event.preventDefault();
|
||||||
const { deltaY } = event;
|
const { deltaY } = event;
|
||||||
if (deltaY > 0) {
|
if (deltaY > 0) {
|
||||||
zoomOut();
|
zoomOut();
|
||||||
} else if (deltaY < 0) {
|
} else if (deltaY < 0 && currentScale < 2) {
|
||||||
zoomIn();
|
zoomIn();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleResize = () => {
|
const handleResize = (event: UIEvent) => {
|
||||||
|
event.preventDefault();
|
||||||
checkZoomSize();
|
checkZoomSize();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -206,7 +212,7 @@ export const useZoomControls = ({
|
|||||||
window.removeEventListener('resize', handleResize);
|
window.removeEventListener('resize', handleResize);
|
||||||
window.removeEventListener('mouseup', handleMouseUp);
|
window.removeEventListener('mouseup', handleMouseUp);
|
||||||
};
|
};
|
||||||
}, [zoomIn, zoomOut, checkZoomSize, handleMouseUp]);
|
}, [zoomIn, zoomOut, checkZoomSize, handleMouseUp, currentScale]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
zoomIn,
|
zoomIn,
|
||||||
|
|||||||
Reference in New Issue
Block a user