Skip to content

Commit

Permalink
fix: check if clientX exists on event
Browse files Browse the repository at this point in the history
  • Loading branch information
sprocketc authored and tiensonqin committed Apr 3, 2023
1 parent 74866b2 commit 891a1dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
Expand Up @@ -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,
})
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions tldraw/packages/react/src/hooks/useCanvasEvents.ts
Expand Up @@ -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>) => {
Expand Down

0 comments on commit 891a1dd

Please sign in to comment.