@@ -3455,46 +3455,41 @@ export class LGraphCanvas
3455
3455
processMouseWheel ( e : WheelEvent ) : void {
3456
3456
if ( ! this . graph || ! this . allow_dragcanvas ) return
3457
3457
3458
- // TODO: Mouse wheel zoom rewrite
3459
- // @ts -expect-error wheelDeltaY is non-standard property on WheelEvent
3460
- const delta = e . wheelDeltaY ?? e . detail * - 60
3461
-
3462
3458
this . adjustMouseEvent ( e )
3463
3459
3464
3460
const pos : Point = [ e . clientX , e . clientY ]
3465
3461
if ( this . viewport && ! isPointInRect ( pos , this . viewport ) ) return
3466
3462
3467
3463
let { scale } = this . ds
3468
3464
3469
- if (
3470
- LiteGraph . canvasNavigationMode === 'legacy' ||
3471
- ( LiteGraph . canvasNavigationMode === 'standard' && e . ctrlKey )
3472
- ) {
3473
- if ( delta > 0 ) {
3474
- scale *= this . zoom_speed
3475
- } else if ( delta < 0 ) {
3476
- scale *= 1 / this . zoom_speed
3477
- }
3478
- this . ds . changeScale ( scale , [ e . clientX , e . clientY ] )
3479
- } else if (
3480
- LiteGraph . macTrackpadGestures &&
3481
- ( ! LiteGraph . macGesturesRequireMac || navigator . userAgent . includes ( 'Mac' ) )
3482
- ) {
3483
- if ( e . metaKey && ! e . ctrlKey && ! e . shiftKey && ! e . altKey ) {
3484
- if ( e . deltaY > 0 ) {
3485
- scale *= 1 / this . zoom_speed
3486
- } else if ( e . deltaY < 0 ) {
3465
+ // Detect if this is a trackpad gesture or mouse wheel
3466
+ const isTrackpad = this . pointer . isTrackpadGesture ( e )
3467
+
3468
+ if ( e . ctrlKey || LiteGraph . canvasNavigationMode === 'legacy' ) {
3469
+ // Legacy mode or standard mode with ctrl - use wheel for zoom
3470
+ if ( isTrackpad ) {
3471
+ // Trackpad gesture - use smooth scaling
3472
+ scale *= 1 + e . deltaY * ( 1 - this . zoom_speed ) * 0.18
3473
+ this . ds . changeScale ( scale , [ e . clientX , e . clientY ] , false )
3474
+ } else {
3475
+ // Mouse wheel - use stepped scaling
3476
+ if ( e . deltaY < 0 ) {
3487
3477
scale *= this . zoom_speed
3478
+ } else if ( e . deltaY > 0 ) {
3479
+ scale *= 1 / this . zoom_speed
3488
3480
}
3489
3481
this . ds . changeScale ( scale , [ e . clientX , e . clientY ] )
3490
- } else if ( e . ctrlKey ) {
3491
- scale *= 1 + e . deltaY * ( 1 - this . zoom_speed ) * 0.18
3492
- this . ds . changeScale ( scale , [ e . clientX , e . clientY ] , false )
3493
- } else if ( e . shiftKey ) {
3494
- this . ds . offset [ 0 ] -= e . deltaY * 1.18 * ( 1 / scale )
3482
+ }
3483
+ } else {
3484
+ // Standard mode without ctrl - use wheel / gestures to pan
3485
+ // Trackpads and mice work on significantly different scales
3486
+ const factor = isTrackpad ? 0.18 : 0.008_333
3487
+
3488
+ if ( ! isTrackpad && e . shiftKey && e . deltaX === 0 ) {
3489
+ this . ds . offset [ 0 ] -= e . deltaY * ( 1 + factor ) * ( 1 / scale )
3495
3490
} else {
3496
- this . ds . offset [ 0 ] -= e . deltaX * 1.18 * ( 1 / scale )
3497
- this . ds . offset [ 1 ] -= e . deltaY * 1.18 * ( 1 / scale )
3491
+ this . ds . offset [ 0 ] -= e . deltaX * ( 1 + factor ) * ( 1 / scale )
3492
+ this . ds . offset [ 1 ] -= e . deltaY * ( 1 + factor ) * ( 1 / scale )
3498
3493
}
3499
3494
}
3500
3495
0 commit comments