Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
code improve
  • Loading branch information
jtydhr88 committed Dec 4, 2025
commit a9d30d8cd670004c3cdc9f92527f4df0651fcfc3
27 changes: 12 additions & 15 deletions src/extensions/core/simpleTouchSupport.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LGraphCanvas, LiteGraph } from '@/lib/litegraph/src/litegraph'

import { app } from '../../scripts/app'
import { app } from '@/scripts/app'

let touchZooming = false
let touchCount = 0
Expand Down Expand Up @@ -82,28 +82,25 @@ app.registerExtension({
}
)

const resetTouchState = () => {
touchCount = 0
touchZooming = false
touchTime = null
lastTouch = null
lastScale = null
touchDist = null
}

// Reset touch state when page loses visibility (e.g., switching apps on iPad)
// This prevents touchCount from getting stuck when touchend events are missed
document.addEventListener('visibilitychange', () => {
if (document.hidden) {
touchCount = 0
touchZooming = false
touchTime = null
lastTouch = null
lastScale = null
touchDist = null
resetTouchState()
}
})

// Also handle touchcancel which fires when touch is interrupted
app.canvasEl.parentElement?.addEventListener('touchcancel', () => {
touchCount = 0
touchZooming = false
touchTime = null
lastTouch = null
lastScale = null
touchDist = null
})
app.canvasEl.parentElement?.addEventListener('touchcancel', resetTouchState)

app.canvasEl.parentElement?.addEventListener(
'touchmove',
Expand Down