Fix context menu bug on mobile

This commit is contained in:
Steve Ruiz 2022-01-08 20:08:17 +00:00
parent 5b13e7f19e
commit f2481642f9
5 changed files with 8 additions and 5 deletions

View file

@ -1,7 +1,5 @@
import type { TLBinding } from '@tldraw/core'
import { nanoid } from 'nanoid'
import type { Shape } from 'shapes'
import type { ArrowShape } from 'shapes/arrow'
import type { CustomBinding } from './constants'
import type { machine } from './machine'

View file

@ -21,10 +21,11 @@ export function useBoundsEvents() {
callbacks.onPointerDown?.(info, e)
},
onPointerUp: (e: React.PointerEvent) => {
if ((e as any).dead) return
else (e as any).dead = true
if (e.button !== 0) return
inputs.activePointer = undefined
if (!inputs.pointerIsValid(e)) return
e.stopPropagation()
const isDoubleClick = inputs.isDoubleClick()
const info = inputs.pointerUp(e, 'bounds')
if (e.currentTarget.hasPointerCapture(e.pointerId)) {

View file

@ -28,6 +28,8 @@ export function useCanvasEvents() {
callbacks.onPointerMove?.(info, e)
},
onPointerUp: (e: React.PointerEvent) => {
if ((e as any).dead) return
else (e as any).dead = true
if (e.button !== 0 && e.button !== 1) return
inputs.activePointer = undefined
if (!inputs.pointerIsValid(e)) return

View file

@ -18,9 +18,10 @@ export function useHandleEvents(id: string) {
callbacks.onPointerDown?.(info, e)
},
onPointerUp: (e: React.PointerEvent) => {
if ((e as any).dead) return
else (e as any).dead = true
if (e.button !== 0) return
if (!inputs.pointerIsValid(e)) return
e.stopPropagation()
const isDoubleClick = inputs.isDoubleClick()
const info = inputs.pointerUp(e, id)
if (e.currentTarget.hasPointerCapture(e.pointerId)) {

View file

@ -36,10 +36,11 @@ export function useShapeEvents(id: string) {
callbacks.onPointerDown?.(info, e)
},
onPointerUp: (e: React.PointerEvent) => {
if ((e as any).dead) return
else (e as any).dead = true
if (e.button !== 0) return
inputs.activePointer = undefined
if (!inputs.pointerIsValid(e)) return
e.stopPropagation()
const isDoubleClick = inputs.isDoubleClick()
const info = inputs.pointerUp(e, id)
if (e.currentTarget.hasPointerCapture(e.pointerId)) {