Line data Source code
1 : /**
2 : * Wheel events whose browser default would break the editing experience.
3 : * On macOS trackpads:
4 : * - `ctrl/meta + wheel` (pinch-zoom) triggers page-level zoom, which
5 : * pushes fixed-position UI (e.g. ComfyActionbar) off-screen with no
6 : * recovery short of a page reload.
7 : * - Horizontal-dominant wheel (two-finger horizontal swipe) triggers
8 : * back/forward navigation, which leaves the workflow.
9 : *
10 : * Equal `|deltaX| == |deltaY|` (including idle 0/0 frames between meaningful
11 : * trackpad samples) intentionally falls on the false branch so native
12 : * vertical scroll wins on a tie.
13 : *
14 : * Components that intercept wheel events should suppress the default for
15 : * these gestures even when they otherwise let the browser scroll natively.
16 : */
17 2356 : export const isCanvasGestureWheel = (event: WheelEvent): boolean =>
18 : event.ctrlKey ||
19 : event.metaKey ||
20 : Math.abs(event.deltaX) > Math.abs(event.deltaY)
|