Browse Source

Fix alt zoom (#424)

main
Steve Ruiz 3 years ago
parent
commit
0334ac0f30
No account linked to committer's email address

+ 2
- 2
packages/core/src/hooks/useZoomEvents.ts View File

@@ -34,6 +34,8 @@ export function useZoomEvents<T extends HTMLElement>(zoom: number, ref: React.Re
34 34
   useGesture(
35 35
     {
36 36
       onWheel: ({ delta, event: e }) => {
37
+        e.preventDefault()
38
+
37 39
         if (e.altKey && e.buttons === 0) {
38 40
           const point = inputs.pointer?.point ?? [bounds.width / 2, bounds.height / 2]
39 41
 
@@ -43,8 +45,6 @@ export function useZoomEvents<T extends HTMLElement>(zoom: number, ref: React.Re
43 45
           return
44 46
         }
45 47
 
46
-        e.preventDefault()
47
-
48 48
         if (inputs.isPinching) return
49 49
 
50 50
         if (Vec.isEqual(delta, [0, 0])) return

+ 1
- 1
packages/tldraw/src/state/TldrawApp.ts View File

@@ -2665,7 +2665,7 @@ export class TldrawApp extends StateManager<TDSnapshot> {
2665 2665
         ? info.delta[2] / 100
2666 2666
         : info.delta[2] / 2
2667 2667
 
2668
-    this.zoomBy(delta, info.delta)
2668
+    this.zoomBy(delta, this.centerPoint)
2669 2669
     this.onPointerMove(info, e as unknown as React.PointerEvent)
2670 2670
   }
2671 2671
 

Loading…
Cancel
Save