fix eruda clicks
This commit is contained in:
parent
34e566aab6
commit
8c7b6f6345
1 changed files with 17 additions and 6 deletions
23
src/index.ts
23
src/index.ts
|
|
@ -634,19 +634,30 @@ async function connect(connectOptions: {
|
|||
|
||||
registerListener(document, 'pointerlockchange', changeCallback, false)
|
||||
|
||||
let holdingTouch: { touch: Touch, elem: HTMLElement } | undefined
|
||||
document.body.addEventListener('touchend', (e) => {
|
||||
if (!isGameActive(true)) return
|
||||
if (holdingTouch?.touch.identifier !== e.changedTouches[0].identifier) return
|
||||
holdingTouch.elem.click()
|
||||
holdingTouch = undefined
|
||||
})
|
||||
document.body.addEventListener('touchstart', (e) => {
|
||||
if (!isGameActive(true)) return
|
||||
e.preventDefault()
|
||||
holdingTouch = {
|
||||
touch: e.touches[0],
|
||||
elem: e.composedPath()[0] as HTMLElement
|
||||
}
|
||||
}, { passive: false })
|
||||
|
||||
const cameraControlEl = hud
|
||||
|
||||
// after what time of holding the finger start breaking the block
|
||||
/** after what time of holding the finger start breaking the block */
|
||||
const touchStartBreakingBlockMs = 500
|
||||
let virtualClickActive = false
|
||||
let virtualClickTimeout
|
||||
let screenTouches = 0
|
||||
let capturedPointer: { id; x; y; sourceX; sourceY; activateCameraMove; time } | null
|
||||
document.body.addEventListener('touchstart', (e) => {
|
||||
if (isGameActive(true)) {
|
||||
e.preventDefault()
|
||||
}
|
||||
}, { passive: false })
|
||||
registerListener(document, 'pointerdown', (e) => {
|
||||
const clickedEl = e.composedPath()[0]
|
||||
if (!isGameActive(true) || !miscUiState.currentTouch || clickedEl !== cameraControlEl || e.pointerId === undefined) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue