@@ -13,9 +13,6 @@ import type {
13
13
MouseMoveInteraction ,
14
14
MouseUpInteraction ,
15
15
WheelPlainInteraction ,
16
- WheelWithShiftInteraction ,
17
- WheelWithControlInteraction ,
18
- WheelWithMetaInteraction ,
19
16
} from './useCanvasInteraction' ;
20
17
import type { Rect } from './geometry' ;
21
18
import type { ScrollState } from './utils/scrollState' ;
@@ -214,51 +211,36 @@ export class HorizontalPanAndZoomView extends View {
214
211
215
212
const absDeltaX = Math . abs ( deltaX ) ;
216
213
const absDeltaY = Math . abs ( deltaY ) ;
217
- if ( absDeltaY > absDeltaX ) {
218
- return ; // Scrolling vertically
219
- }
220
- if ( absDeltaX < MOVE_WHEEL_DELTA_THRESHOLD ) {
221
- return ;
222
- }
223
-
224
- const newState = translateState ( {
225
- state : this . _scrollState ,
226
- delta : - deltaX ,
227
- containerLength : this . frame . size . width ,
228
- } ) ;
229
- this . _setStateAndInformCallbacksIfChanged ( newState ) ;
230
- }
231
-
232
- _handleWheelZoom (
233
- interaction :
234
- | WheelWithShiftInteraction
235
- | WheelWithControlInteraction
236
- | WheelWithMetaInteraction ,
237
- ) {
238
- const {
239
- location ,
240
- delta : { deltaY } ,
241
- } = interaction . payload ;
242
214
243
- if ( ! rectContainsPoint ( location , this . frame ) ) {
244
- return ; // Not scrolling on view
245
- }
246
-
247
- const absDeltaY = Math . abs ( deltaY ) ;
248
- if ( absDeltaY < MOVE_WHEEL_DELTA_THRESHOLD ) {
249
- return ;
215
+ // Vertical scrolling zooms in and out (unless the SHIFT modifier is used).
216
+ // Horizontal scrolling pans.
217
+ if ( absDeltaY > absDeltaX ) {
218
+ if ( absDeltaY < MOVE_WHEEL_DELTA_THRESHOLD ) {
219
+ return ;
220
+ }
221
+
222
+ const newState = zoomState ( {
223
+ state : this . _scrollState ,
224
+ multiplier : 1 + 0.005 * - deltaY ,
225
+ fixedPoint : location . x - this . _scrollState . offset ,
226
+
227
+ minContentLength : this . _intrinsicContentWidth * MIN_ZOOM_LEVEL ,
228
+ maxContentLength : this . _intrinsicContentWidth * MAX_ZOOM_LEVEL ,
229
+ containerLength : this . frame . size . width ,
230
+ } ) ;
231
+ this . _setStateAndInformCallbacksIfChanged ( newState ) ;
232
+ } else {
233
+ if ( absDeltaX < MOVE_WHEEL_DELTA_THRESHOLD ) {
234
+ return ;
235
+ }
236
+
237
+ const newState = translateState ( {
238
+ state : this . _scrollState ,
239
+ delta : - deltaX ,
240
+ containerLength : this . frame . size . width ,
241
+ } ) ;
242
+ this . _setStateAndInformCallbacksIfChanged ( newState ) ;
250
243
}
251
-
252
- const newState = zoomState ( {
253
- state : this . _scrollState ,
254
- multiplier : 1 + 0.005 * - deltaY ,
255
- fixedPoint : location . x - this . _scrollState . offset ,
256
-
257
- minContentLength : this . _intrinsicContentWidth * MIN_ZOOM_LEVEL ,
258
- maxContentLength : this . _intrinsicContentWidth * MAX_ZOOM_LEVEL ,
259
- containerLength : this . frame . size . width ,
260
- } ) ;
261
- this . _setStateAndInformCallbacksIfChanged ( newState ) ;
262
244
}
263
245
264
246
handleInteraction ( interaction : Interaction , viewRefs : ViewRefs ) {
@@ -275,11 +257,6 @@ export class HorizontalPanAndZoomView extends View {
275
257
case 'wheel-plain' :
276
258
this . _handleWheelPlain ( interaction ) ;
277
259
break ;
278
- case 'wheel-shift' :
279
- case 'wheel-control' :
280
- case 'wheel-meta' :
281
- this . _handleWheelZoom ( interaction ) ;
282
- break ;
283
260
}
284
261
}
285
262
}
0 commit comments