@@ -14,6 +14,7 @@ export const sessionFullscreenState = writable<boolean | undefined>(undefined);
1414
1515export function initPanzoom ( node : HTMLElement ) {
1616 container = node ;
17+
1718 pz = panzoom ( node , {
1819 bounds : false ,
1920 maxZoom : 10 ,
@@ -29,7 +30,12 @@ export function initPanzoom(node: HTMLElement) {
2930 // This allows text selection within text boxes
3031 return isTextBox ;
3132 } ,
32- beforeWheel : ( e ) => ! e . ctrlKey ,
33+ // When swapWheelBehavior is true: zoom without modifier, scroll with Ctrl
34+ // When swapWheelBehavior is false (default): scroll without modifier, zoom with Ctrl
35+ beforeWheel : ( e ) => {
36+ const swapWheelBehavior = get ( settings ) . swapWheelBehavior ;
37+ return swapWheelBehavior ? e . ctrlKey : ! e . ctrlKey ;
38+ } ,
3339 onTouch : ( e ) => e . touches . length > 1 ,
3440 // Panzoom typing is wrong here
3541 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -49,14 +55,19 @@ export function initPanzoom(node: HTMLElement) {
4955 pz . on ( 'pan' , ( ) => keepInBounds ( ) ) ;
5056 pz . on ( 'zoom' , ( ) => keepInBounds ( ) ) ;
5157
52- // Add custom wheel handler for panning when Ctrl is not pressed
58+ // Add custom wheel handler for panning/zooming based on swapWheelBehavior
5359 const wheelHandler = ( e : WheelEvent ) => {
54- if ( ! e . ctrlKey && pz ) {
55- e . preventDefault ( ) ;
56- const { x, y } = pz . getTransform ( ) ;
57- // Pan vertically based on wheel deltaY
58- pz . moveTo ( x , y - e . deltaY ) ;
59- keepInBounds ( ) ;
60+ if ( pz ) {
61+ const swapWheelBehavior = get ( settings ) . swapWheelBehavior ;
62+ const shouldPan = swapWheelBehavior ? e . ctrlKey : ! e . ctrlKey ;
63+
64+ if ( shouldPan ) {
65+ e . preventDefault ( ) ;
66+ const { x, y } = pz . getTransform ( ) ;
67+ // Pan vertically based on wheel deltaY
68+ pz . moveTo ( x , y - e . deltaY ) ;
69+ keepInBounds ( ) ;
70+ }
6071 }
6172 } ;
6273
0 commit comments