From adc53afbe336a7602a45e1aa0a024341ac781032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mitja=20Bezen=C5=A1ek?= Date: Thu, 29 Feb 2024 12:27:16 +0100 Subject: [PATCH] Don't allow edge scrolling when camera is frozen. (#2992) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't allow edge scrolling when camera is frozen. ### Change Type - [x] `patch` — Bug fix - [ ] `minor` — New feature - [ ] `major` — Breaking change - [ ] `dependencies` — Changes to package dependencies[^1] - [ ] `documentation` — Changes to the documentation only[^2] - [ ] `tests` — Changes to any test code only[^2] - [ ] `internal` — Any other changes that don't affect the published package[^2] - [ ] I don't know [^1]: publishes a `patch` release, for devDependencies use `internal` [^2]: will not publish a new version ### Testing It's a bit hard to test this, you actually need to change the code a bit. 1. Add an `onMount` handler to the `Tldraw` component in `develop.tsx` 2. In the `onMount` handler add: `editor.updateInstanceState({canMoveCamera: false})` to freeze the camera. 3. Make sure edge scrolling is turned on in the preferences. 4. Use brush selections / resizing / translating close to the edges. 5. The camera should not move. ### Release Notes - Don't allow edge scrolling when camera is frozen. --- packages/editor/src/lib/utils/edgeScrolling.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/editor/src/lib/utils/edgeScrolling.ts b/packages/editor/src/lib/utils/edgeScrolling.ts index b79f16092..b89e804fe 100644 --- a/packages/editor/src/lib/utils/edgeScrolling.ts +++ b/packages/editor/src/lib/utils/edgeScrolling.ts @@ -33,7 +33,12 @@ function getEdgeProximityFactor( * @public */ export function moveCameraWhenCloseToEdge(editor: Editor) { - if (!editor.inputs.isDragging || editor.inputs.isPanning) return + if ( + !editor.inputs.isDragging || + editor.inputs.isPanning || + !editor.getInstanceState().canMoveCamera + ) + return const { inputs: {