Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat: change img zoom in gallery on wheel Event (#6333)

Roman Sergeevb9973017a5e0
diff --git a/packages/design/src/components/gallery/Gallery.tsx b/packages/design/src/components/gallery/Gallery.tsx
index 5337bff3e8..9ba71c7c16 100644
--- a/packages/design/src/components/gallery/Gallery.tsx
+++ b/packages/design/src/components/gallery/Gallery.tsx
@@ -73,6 +73,22 @@ export function Gallery(props: IGalleryProps) {
}
}, [open]);
+ // wheel
+ useEffect(() => {
+ if (!open) return;
+
+ const handleWheel = (e: WheelEvent) => {
+ e.preventDefault();
+ const step = -e.deltaY * 0.001;
+ setZoomLevel((prev) => Math.min(Math.max(0.5, prev + step), 2));
+ };
+
+ window.addEventListener('wheel', handleWheel, { passive: false });
+ return () => {
+ window.removeEventListener('wheel', handleWheel);
+ };
+ }, [open]);
+
if (!open && !isVisible) return null;
function handleToggleZoom(ratio: number | 'reset') {