feat(nodes): add effect scope to useDrag utility

This commit is contained in:
bcakmakoglu
2022-06-07 18:33:00 +02:00
committed by Braks
parent f434ab0f79
commit 382a3b67fc
@@ -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
} }