From 28f5af23e806311cd83e677c483d2ee5836d0f48 Mon Sep 17 00:00:00 2001 From: Alexey Morozov Date: Wed, 25 Mar 2026 23:13:20 +0300 Subject: [PATCH] Make `ZoomOptions.requireCtrl` default to `false` to zoom without holding `Ctrl` i.e. like on a map --- CHANGELOG.md | 1 + src/diagram/canvasApi.ts | 4 ++-- src/diagram/canvasArea.tsx | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7acc7ba3..1c6f058d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p * Allow to select multiple elements with `Selection` with touch when `CanvasApi.pointerMode` is `selection`; * Allow to establish new links with `SelectionActionEstablishLink` on touchscreen; * Allow to move link source or target with `LinkActionMoveEndpoint` on touchscreen; + * Make `ZoomOptions.requireCtrl` default to `false` to zoom without holding `Ctrl` i.e. like on a map. * Enable `showPointerModeToggle` on `ZoomControl` by default (can be disabled by passing `false`). - **[💥Breaking]** Extend and make optional built-in property editing form support: * Extract property editor inputs into separate entry point `@reactodia/workspace/forms` to be able to use external forms implementation without always bundling the built-in one; diff --git a/src/diagram/canvasApi.ts b/src/diagram/canvasApi.ts index cc2b8638..9c649bac 100644 --- a/src/diagram/canvasApi.ts +++ b/src/diagram/canvasApi.ts @@ -413,10 +413,10 @@ export interface ZoomOptions { * with the mouse wheel. * * If `true`, the mouse wheel will be used to scroll viewport - * horizontally or vertically if `Shift` is held; + * horizontally (or vertically if `Shift` is held); * otherwise the wheel action will be inverted. * - * @default true + * @default false */ requireCtrl?: boolean; } diff --git a/src/diagram/canvasArea.tsx b/src/diagram/canvasArea.tsx index 616b16da..49054c0a 100644 --- a/src/diagram/canvasArea.tsx +++ b/src/diagram/canvasArea.tsx @@ -471,6 +471,7 @@ class CanvasController implements CanvasApi { return this.isEventFromCellLayer(e) && target instanceof Node && ( this.paper.root === target || this.paper.pane === target || + this.paper.pane?.firstChild === target || ( !hasScrollableParent(target, this.linkLayer.current) && !hasScrollableParent(target, this.labelLayer.current) && @@ -512,6 +513,7 @@ class CanvasController implements CanvasApi { return target instanceof Node && Boolean( this.paper.root === target || this.paper.pane === target || + this.paper.pane?.firstChild === target || this.linkLayer.current?.contains(target) || this.labelLayer.current?.contains(target) || this.elementLayer.current?.contains(target) @@ -676,7 +678,7 @@ function zoomOptionsWithDefaults(zoomOptions: ZoomOptions = {}): Required