feat(nodes): add effect scope to useDrag utility
This commit is contained in:
@@ -22,6 +22,8 @@ interface UseDragParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function useDrag(params: UseDragParams) {
|
function useDrag(params: UseDragParams) {
|
||||||
|
const scope = effectScope()
|
||||||
|
const dragging = scope.run(() => {
|
||||||
const {
|
const {
|
||||||
viewport,
|
viewport,
|
||||||
snapToGrid,
|
snapToGrid,
|
||||||
@@ -36,6 +38,7 @@ function useDrag(params: UseDragParams) {
|
|||||||
setState,
|
setState,
|
||||||
updateNodePositions,
|
updateNodePositions,
|
||||||
} = $(useVueFlow())
|
} = $(useVueFlow())
|
||||||
|
|
||||||
const { onStart, onDrag, onStop, el, disabled = false, noDragClassName, id, handleSelector } = $(params)
|
const { onStart, onDrag, onStop, el, disabled = false, noDragClassName, id, handleSelector } = $(params)
|
||||||
|
|
||||||
const dragging = ref(false)
|
const dragging = ref(false)
|
||||||
@@ -147,6 +150,11 @@ function useDrag(params: UseDragParams) {
|
|||||||
{ flush: 'post' },
|
{ flush: 'post' },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return dragging
|
||||||
|
})
|
||||||
|
|
||||||
|
tryOnScopeDispose(() => scope.stop())
|
||||||
|
|
||||||
return dragging
|
return dragging
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user