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:
filtered
2025-05-04 11:58:24 +10:00
committed by GitHub
parent bfc87af9d1
commit 81eed7a1fa
3 changed files with 33 additions and 2 deletions

View File

@@ -276,6 +276,22 @@ export class LiteGraphGlobal {
*/
onDeprecationWarning: ((message: string, source?: object) => void)[] = [console.warn]
/**
* If `true`, mouse wheel events will be interpreted as trackpad gestures.
* Tested on MacBook M4 Pro.
* @default false
* @see macGesturesRequireMac
*/
macTrackpadGestures: boolean = false
/**
* If both this setting and {@link macTrackpadGestures} are `true`, trackpad gestures will
* only be enabled when the browser user agent includes "Mac".
* @default true
* @see macTrackpadGestures
*/
macGesturesRequireMac: boolean = true
// TODO: Remove legacy accessors
LGraph = LGraph
LLink = LLink