1- import { useEventListener } from '@vueuse/core'
1+ import { tryOnScopeDispose , useEventListener } from '@vueuse/core'
22import type { Fn } from '@vueuse/core'
3- import { onBeforeUnmount } from 'vue'
43
54import { useSharedCanvasPositionConversion } from '@/composables/element/useCanvasPositionConversion'
65import type { LGraph } from '@/lib/litegraph/src/LGraph'
@@ -555,6 +554,8 @@ export function useSlotLinkInteraction({
555554 if ( event . button !== 0 ) return
556555 if ( ! nodeId ) return
557556 if ( pointerSession . isActive ( ) ) return
557+ event . preventDefault ( )
558+ event . stopPropagation ( )
558559
559560 const canvas = app . canvas
560561 const graph = canvas ?. graph
@@ -613,7 +614,7 @@ export function useSlotLinkInteraction({
613614
614615 if ( shouldBatchDisconnectOutputLinks && resolvedNode ) {
615616 resolvedNode . disconnectOutput ( index )
616- app . canvas ? .setDirty ( true , true )
617+ canvas . setDirty ( true , true )
617618 event . preventDefault ( )
618619 event . stopPropagation ( )
619620 return
@@ -634,20 +635,18 @@ export function useSlotLinkInteraction({
634635 const shouldMoveExistingInput =
635636 isInputSlot && ! shouldBreakExistingInputLink && hasExistingInputLink
636637
637- if ( activeAdapter ) {
638- if ( isOutputSlot ) {
639- activeAdapter . beginFromOutput ( localNodeId , index , {
640- moveExisting : shouldMoveExistingOutput
641- } )
642- } else {
643- activeAdapter . beginFromInput ( localNodeId , index , {
644- moveExisting : shouldMoveExistingInput
645- } )
646- }
638+ if ( isOutputSlot ) {
639+ activeAdapter . beginFromOutput ( localNodeId , index , {
640+ moveExisting : shouldMoveExistingOutput
641+ } )
642+ } else {
643+ activeAdapter . beginFromInput ( localNodeId , index , {
644+ moveExisting : shouldMoveExistingInput
645+ } )
646+ }
647647
648- if ( shouldMoveExistingInput && existingInputLink ) {
649- existingInputLink . _dragging = true
650- }
648+ if ( shouldMoveExistingInput && existingInputLink ) {
649+ existingInputLink . _dragging = true
651650 }
652651
653652 syncRenderLinkOrigins ( )
@@ -678,21 +677,19 @@ export function useSlotLinkInteraction({
678677 toCanvasPointerEvent ( event )
679678 updatePointerState ( event )
680679
681- if ( activeAdapter ) {
682- activeAdapter . linkConnector . state . snapLinksPos = [
683- state . pointer . canvas . x ,
684- state . pointer . canvas . y
685- ]
686- }
680+ activeAdapter . linkConnector . state . snapLinksPos = [
681+ state . pointer . canvas . x ,
682+ state . pointer . canvas . y
683+ ]
687684
688685 pointerSession . register (
689- useEventListener ( window , 'pointermove' , handlePointerMove , {
686+ useEventListener ( 'pointermove' , handlePointerMove , {
690687 capture : true
691688 } ) ,
692- useEventListener ( window , 'pointerup' , handlePointerUp , {
689+ useEventListener ( 'pointerup' , handlePointerUp , {
693690 capture : true
694691 } ) ,
695- useEventListener ( window , 'pointercancel' , handlePointerCancel , {
692+ useEventListener ( 'pointercancel' , handlePointerCancel , {
696693 capture : true
697694 } )
698695 )
@@ -710,12 +707,10 @@ export function useSlotLinkInteraction({
710707 : activeAdapter . isOutputValidDrop ( slotLayout . nodeId , idx )
711708 setCompatibleForKey ( key , ok )
712709 }
713- app . canvas ?. setDirty ( true , true )
714- event . preventDefault ( )
715- event . stopPropagation ( )
710+ canvas . setDirty ( true , true )
716711 }
717712
718- onBeforeUnmount ( ( ) => {
713+ tryOnScopeDispose ( ( ) => {
719714 if ( pointerSession . isActive ( ) ) {
720715 cleanupInteraction ( )
721716 }
0 commit comments