fix(nodes): Add draggable watchers

This commit is contained in:
Braks
2022-04-24 13:34:22 +02:00
parent f69118e265
commit 4eb775477f
2 changed files with 27 additions and 2 deletions
+26 -1
View File
@@ -43,7 +43,7 @@ watch(
const nodeElement = ref()
const { scale, onDrag, onDragStart, onDragStop } = useDraggableCore(nodeElement, {
const { scale, disabled, handle, cancel, grid, onDrag, onDragStart, onDragStop } = useDraggableCore(nodeElement, {
handle: node.dragHandle,
disabled: !draggable,
grid: snapGrid,
@@ -64,6 +64,31 @@ onMounted(() => {
},
{ debounce: 5, flush: 'post' },
)
watch(
() => draggable,
() => {
disabled.value = !draggable
},
)
watch(
() => node.dragHandle,
() => {
if (node.dragHandle) handle.value = node.dragHandle
},
)
watch($$(noDragClassName), () => {
if (noDragClassName) cancel.value = noDragClassName as any
})
watch(
() => snapGrid,
() => {
if (grid) grid.value = snapGrid
},
)
})
onMounted(() => {
@@ -18,7 +18,7 @@ const innerStyle = computed(() => ({
const transform = computed(() => `translate(${viewport.x}px,${viewport.y}px) scale(${viewport.zoom})`)
watch(selectedNodesBBox, (v) => {
watch($$(selectedNodesBBox), (v) => {
setState({
selectedNodesBbox: v,
})