@@ -26,7 +26,12 @@ import {
2626 handleWheelZoom ,
2727 handleWheelStop ,
2828} from "./wheel/wheel.logic" ;
29- import { isPanningAllowed , isPanningStartAllowed } from "./pan/panning.utils" ;
29+ import {
30+ getPaddingValue ,
31+ handleNewPosition ,
32+ isPanningAllowed ,
33+ isPanningStartAllowed ,
34+ } from "./pan/panning.utils" ;
3035import {
3136 handlePanning ,
3237 handlePanningEnd ,
@@ -68,6 +73,7 @@ export class ZoomPanPinch {
6873 public wheelAnimationTimer : ReturnType < typeof setTimeout > | null = null ;
6974 // panning helpers
7075 public isPanning = false ;
76+ public isWheelPanning = false ;
7177 public startCoords : StartCoordsType = null ;
7278 public lastTouch : number | null = null ;
7379 // pinch helpers
@@ -112,6 +118,11 @@ export class ZoomPanPinch {
112118 const passive = makePassiveEventOption ( ) ;
113119 const currentDocument = this . wrapperComponent ?. ownerDocument ;
114120 const currentWindow = currentDocument ?. defaultView ;
121+ this . wrapperComponent ?. addEventListener (
122+ "wheel" ,
123+ this . onWheelPanning ,
124+ passive ,
125+ ) ;
115126 // Panning on window to allow panning when mouse is out of component wrapper
116127 currentWindow ?. addEventListener ( "mousedown" , this . onPanningStart , passive ) ;
117128 currentWindow ?. addEventListener ( "mousemove" , this . onPanning , passive ) ;
@@ -197,6 +208,44 @@ export class ZoomPanPinch {
197208 // Pan
198209 /// ///////
199210
211+ onWheelPanning = ( event : WheelEvent ) : void => {
212+ const { disabled, wheel, panning } = this . setup ;
213+ if (
214+ ! this . wrapperComponent ||
215+ ! this . contentComponent ||
216+ disabled ||
217+ ! wheel . wheelDisabled ||
218+ panning . disabled ||
219+ ! panning . wheelPanning ||
220+ event . ctrlKey
221+ ) {
222+ return ;
223+ }
224+
225+ event . preventDefault ( ) ;
226+ event . stopPropagation ( ) ;
227+
228+ const { positionX, positionY } = this . transformState ;
229+ const mouseX = positionX - event . deltaX ;
230+ const mouseY = positionY - event . deltaY ;
231+ const newPositionX = panning . lockAxisX ? positionX : mouseX ;
232+ const newPositionY = panning . lockAxisY ? positionY : mouseY ;
233+
234+ const { sizeX, sizeY } = this . setup . alignmentAnimation ;
235+ const paddingValueX = getPaddingValue ( this , sizeX ) ;
236+ const paddingValueY = getPaddingValue ( this , sizeY ) ;
237+
238+ if ( newPositionX === positionX && newPositionY === positionY ) return ;
239+
240+ handleNewPosition (
241+ this ,
242+ newPositionX ,
243+ newPositionY ,
244+ paddingValueX ,
245+ paddingValueY ,
246+ ) ;
247+ } ;
248+
200249 onPanningStart = ( event : MouseEvent ) : void => {
201250 const { disabled } = this . setup ;
202251 const { onPanningStart } = this . props ;
0 commit comments