Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(whiteboard): only allow pan when middle button is pressed

austaras6915c9c2a508
diff --git a/libs/components/board-state/src/tldraw-app.ts b/libs/components/board-state/src/tldraw-app.ts
index e4b7a8a34f..5dd9ad09b2 100644
--- a/libs/components/board-state/src/tldraw-app.ts
+++ b/libs/components/board-state/src/tldraw-app.ts
@@ -3841,7 +3841,7 @@ export class TldrawApp extends StateManager<TDSnapshot> {
private get_viewbox_from_svg = (svgStr: string | ArrayBuffer | null) => {
if (typeof svgStr === 'string') {
- let viewBox = new DOMParser().parseFromString(svgStr, 'text/xml');
+ const viewBox = new DOMParser().parseFromString(svgStr, 'text/xml');
return viewBox.children[0].getAttribute('viewBox');
}
@@ -4125,7 +4125,7 @@ export class TldrawApp extends StateManager<TDSnapshot> {
};
onPointerDown: TLPointerEventHandler = (info, e) => {
- if (e.buttons === 4) {
+ if (e.button === 1) {
this.patchState({
settings: {
forcePanning: true,
@@ -4142,6 +4142,13 @@ export class TldrawApp extends StateManager<TDSnapshot> {
};
onPointerUp: TLPointerEventHandler = (info, e) => {
+ if (e.button === 1) {
+ this.patchState({
+ settings: {
+ forcePanning: false,
+ },
+ });
+ }
this.isPointing = false;
this.updateInputs(info, e);
this.currentTool.onPointerUp?.(info, e);