Add touch screen dragging support to minimap (#4781)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: snomiao <7323030+snomiao@users.noreply.github.com>
This commit is contained in:
Copilot
2025-08-07 17:36:27 +08:00
committed by GitHub
parent 04f8ae416f
commit e77411d9da
3 changed files with 126 additions and 38 deletions

View File

@@ -4,10 +4,10 @@
ref="containerRef"
class="litegraph-minimap absolute bottom-[20px] right-[90px] z-[1000]"
:style="containerStyles"
@mousedown="handleMouseDown"
@mousemove="handleMouseMove"
@mouseup="handleMouseUp"
@mouseleave="handleMouseUp"
@pointerdown="handlePointerDown"
@pointermove="handlePointerMove"
@pointerup="handlePointerUp"
@pointerleave="handlePointerUp"
@wheel="handleWheel"
>
<canvas
@@ -40,9 +40,9 @@ const {
height,
init,
destroy,
handleMouseDown,
handleMouseMove,
handleMouseUp,
handlePointerDown,
handlePointerMove,
handlePointerUp,
handleWheel
} = minimap

View File

@@ -434,13 +434,14 @@ export function useMinimap() {
const { startSync: startViewportSync, stopSync: stopViewportSync } =
useCanvasTransformSync(updateViewport, { autoStart: false })
const handleMouseDown = (e: MouseEvent) => {
// Pointer event handlers for touch screen support
const handlePointerDown = (e: PointerEvent) => {
isDragging.value = true
updateContainerRect()
handleMouseMove(e)
handlePointerMove(e)
}
const handleMouseMove = (e: MouseEvent) => {
const handlePointerMove = (e: PointerEvent) => {
if (!isDragging.value || !canvasRef.value || !canvas.value) return
const x = e.clientX - containerRect.value.left
@@ -455,7 +456,7 @@ export function useMinimap() {
centerViewOn(worldX, worldY)
}
const handleMouseUp = () => {
const handlePointerUp = () => {
isDragging.value = false
}
@@ -695,9 +696,9 @@ export function useMinimap() {
init,
destroy,
toggle,
handleMouseDown,
handleMouseMove,
handleMouseUp,
handlePointerDown,
handlePointerMove,
handlePointerUp,
handleWheel,
setMinimapRef
}