浏览代码

fix: check if clientX exists on event

Konstantinos Kaloutas 2 年之前
父节点
当前提交
891a1ddbb5

+ 7 - 5
tldraw/packages/core/src/lib/tools/TLSelectTool/states/PointingMinimapState.ts

@@ -66,11 +66,13 @@ export class PointingMinimapState<
   }
 
   onPointerMove: TLEvents<S>['pointer'] = (info, e) => {
-    const newCameraPoint = this.getCameraPoint([e.clientX, e.clientY])
-    if (newCameraPoint) {
-      this.app.viewport.update({
-        point: newCameraPoint,
-      })
+    if ('clientX' in e) {
+      const newCameraPoint = this.getCameraPoint([e.clientX, e.clientY])
+      if (newCameraPoint) {
+        this.app.viewport.update({
+          point: newCameraPoint,
+        })
+      }
     }
   }
 

+ 4 - 2
tldraw/packages/react/src/hooks/useCanvasEvents.ts

@@ -59,8 +59,10 @@ export function useCanvasEvents() {
     const onDrop = async (e: React.DragEvent<Element>) => {
       e.preventDefault()
 
-      const point = [e.clientX, e.clientY]
-      app.drop(e.dataTransfer, point)
+      if ('clientX' in e) {
+        const point = [e.clientX, e.clientY]
+        app.drop(e.dataTransfer, point)
+      }
     }
 
     const onDragOver = (e: React.DragEvent<Element>) => {