File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -51,12 +51,22 @@ const Zoom = () => {
5151 if ( selectedTool == Tool . Pan ) {
5252 d3 . select ( `#${ ids . workspace } ` ) . call ( zoom ) ;
5353 } else {
54- d3 . select ( `# ${ ids . workspace } ` )
54+ selection
5555 . call ( zoom )
5656 . on ( "mousedown.zoom" , null )
5757 . on ( "touchstart.zoom" , null )
5858 . on ( "touchmove.zoom" , null )
59- . on ( "touchend.zoom" , null ) ;
59+ . on ( "touchend.zoom" , null )
60+ . on ( "wheel.zoom" , ( e ) => {
61+ e . preventDefault ( ) ;
62+ const currentZoom = selection . property ( "__zoom" ) . k || 1 ;
63+ if ( e . ctrlKey ) {
64+ const nextZoom = currentZoom * Math . pow ( 2 , - e . deltaY * 0.01 ) ;
65+ zoom . scaleTo ( selection , nextZoom , d3 . pointer ( e ) ) ;
66+ } else {
67+ zoom . translateBy ( selection , - ( e . deltaX / currentZoom ) , - ( e . deltaY / currentZoom ) ) ;
68+ }
69+ } ) ;
6070 }
6171 } , [ selectedTool ] ) ;
6272
You can’t perform that action at this time.
0 commit comments