@@ -43,7 +43,7 @@ const ZoomPanContainer = React.forwardRef<HTMLDivElement, ZoomPanContainerProps>
4343 minScale = 0.25 ,
4444 maxScale = 5 ,
4545 initialScale = 1 ,
46- zoomStep = 0.25 ,
46+ zoomStep = 0.05 ,
4747 disableControls = false ,
4848 disablePan = false ,
4949 disableZoom = false ,
@@ -119,10 +119,11 @@ const ZoomPanContainer = React.forwardRef<HTMLDivElement, ZoomPanContainerProps>
119119 }
120120 const direction = deltaY > 0 ? - 1 : 1 ;
121121 const magnitude = Math . min ( Math . abs ( deltaY ) / 300 , 1.5 ) ;
122- const factor = 1 + effectiveZoomStep * magnitude ;
122+ const stepCount = Math . max ( 1 , Math . round ( magnitude ) ) ;
123+ const deltaScale = effectiveZoomStep * stepCount ;
123124 const nextScale = direction > 0
124- ? scaleRef . current * factor
125- : scaleRef . current / factor ;
125+ ? scaleRef . current + deltaScale
126+ : scaleRef . current - deltaScale ;
126127 setScale ( nextScale ) ;
127128 return ;
128129 }
@@ -193,8 +194,8 @@ const ZoomPanContainer = React.forwardRef<HTMLDivElement, ZoomPanContainerProps>
193194 }
194195 event . preventDefault ( ) ;
195196 const isZoomOut = event . shiftKey || event . altKey || event . button === 1 ;
196- const factor = 1 + effectiveZoomStep ;
197- setScale ( isZoomOut ? scaleRef . current / factor : scaleRef . current * factor ) ;
197+ const deltaScale = effectiveZoomStep ;
198+ setScale ( isZoomOut ? scaleRef . current - deltaScale : scaleRef . current + deltaScale ) ;
198199 } , [ disableZoom , effectiveZoomStep , setScale ] ) ;
199200
200201 const handleResetView = useCallback ( ( ) => {
@@ -296,7 +297,7 @@ const ZoomPanContainer = React.forwardRef<HTMLDivElement, ZoomPanContainerProps>
296297 tooltip = "Zoom out"
297298 variant = "ghost"
298299 size = "sm"
299- onClick = { ( ) => setScale ( scaleRef . current / ( 1 + zoomStep ) ) }
300+ onClick = { ( ) => setScale ( scaleRef . current - zoomStep ) }
300301 className = "text-text-secondary"
301302 >
302303 < MinusIcon className = "w-4 h-4" />
@@ -308,7 +309,7 @@ const ZoomPanContainer = React.forwardRef<HTMLDivElement, ZoomPanContainerProps>
308309 tooltip = "Zoom in"
309310 variant = "ghost"
310311 size = "sm"
311- onClick = { ( ) => setScale ( scaleRef . current * ( 1 + zoomStep ) ) }
312+ onClick = { ( ) => setScale ( scaleRef . current + zoomStep ) }
312313 className = "text-text-secondary"
313314 >
314315 < PlusIcon className = "w-4 h-4" />
0 commit comments