mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-28 02:02:08 +00:00
Add macOS trackpad gesture support (#1007)
Adds trackpad gesture support to canvas interaction. Supports: - Pinch to zoom - Two-finger panning Feature is off by default. Also by default, the browser user-agent must include "Mac" (even if the feature has been enabled). ```ts // Enable mac trackpad gestures LiteGraph.macTrackpadGestures = true // Disable the default Mac user-agent check LiteGraph.macGesturesRequireMac = false ```
This commit is contained in:
@@ -2968,8 +2968,21 @@ export class LGraphCanvas {
|
||||
|
||||
let { scale } = this.ds
|
||||
|
||||
if (delta > 0) scale *= this.zoom_speed
|
||||
else if (delta < 0) scale *= 1 / this.zoom_speed
|
||||
if (
|
||||
LiteGraph.macTrackpadGestures &&
|
||||
(!LiteGraph.macGesturesRequireMac || navigator.userAgent.includes("Mac"))
|
||||
) {
|
||||
if (e.ctrlKey && !Number.isInteger(e.deltaY)) {
|
||||
scale *= 1 + e.deltaY * (1 - this.zoom_speed) * 0.18
|
||||
} else {
|
||||
this.ds.offset[0] -= e.deltaX * 1.18 * (1 / scale)
|
||||
this.ds.offset[1] -= e.deltaY * 1.18 * (1 / scale)
|
||||
}
|
||||
} else if (delta > 0) {
|
||||
scale *= this.zoom_speed
|
||||
} else if (delta < 0) {
|
||||
scale *= 1 / (this.zoom_speed)
|
||||
}
|
||||
|
||||
this.ds.changeScale(scale, [e.clientX, e.clientY])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user