mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 03:01:54 +00:00
refactor: use read_only as signal, let events bubble to litegraph
- Set canvas.read_only directly when spacebar pressed - Skip stopPropagation when read_only is true in slot link handler - Remove manual dragging_canvas and processMouseMove management - Litegraph handles panning through its normal event handlers
This commit is contained in:
@@ -32,17 +32,8 @@ watch(space, (isPressed) => {
|
|||||||
if (activeElement.value === canvas.canvas) return
|
if (activeElement.value === canvas.canvas) return
|
||||||
if (isEditableElement(activeElement.value || null)) return
|
if (isEditableElement(activeElement.value || null)) return
|
||||||
|
|
||||||
// Mirror litegraph's processKey behavior for spacebar
|
// pointer events will bubble to litegraph
|
||||||
if (isPressed) {
|
canvas.read_only = isPressed
|
||||||
canvas.read_only = true
|
|
||||||
// Set dragging_canvas based on current pointer state
|
|
||||||
if (canvas.pointer?.isDown) {
|
|
||||||
canvas.dragging_canvas = true
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
canvas.read_only = false
|
|
||||||
canvas.dragging_canvas = false
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export function useNodePointerInteractions(
|
export function useNodePointerInteractions(
|
||||||
|
|||||||
@@ -410,13 +410,8 @@ export function useSlotLinkInteraction({
|
|||||||
const handlePointerMove = (event: PointerEvent) => {
|
const handlePointerMove = (event: PointerEvent) => {
|
||||||
if (!pointerSession.matches(event)) return
|
if (!pointerSession.matches(event)) return
|
||||||
|
|
||||||
const canvas = app.canvas
|
// When in panning mode (read_only), let events bubble to litegraph
|
||||||
// When spacebar is held (read_only=true) and left mouse button is down,
|
if (app.canvas?.read_only) return
|
||||||
// delegate to litegraph's processMouseMove for panning
|
|
||||||
const isLeftButtonDown = (event.buttons & 1) !== 0
|
|
||||||
if (canvas?.read_only && isLeftButtonDown) {
|
|
||||||
canvas.processMouseMove(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user