|
|
@ -60,7 +60,7 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script lang="ts" setup> |
|
|
|
import node from './node.vue' |
|
|
|
// import node from './node.vue' |
|
|
|
import { inject, ref, provide, renderSlot, useSlots, watch, readonly, computed } from 'vue' |
|
|
|
import { isChildOf } from './util' |
|
|
|
import renderNode from './renderNode' |
|
|
@ -112,7 +112,7 @@ const emit = defineEmits<{ |
|
|
|
(e: 'onDragover', key: INiuTreeKey): void |
|
|
|
(e: 'onDragleave', key: INiuTreeKey): void |
|
|
|
}>() |
|
|
|
const draggable = opts.sort?readonly(ref(false)):ref(true) |
|
|
|
const draggable = ref(true) |
|
|
|
const status = ref<ENiuTreeStatus>() |
|
|
|
const nodeEL = ref<HTMLDivElement>() |
|
|
|
provide("draggable", draggable) |
|
|
@ -160,11 +160,11 @@ function onDragover(event: DragEvent) { |
|
|
|
return |
|
|
|
const y = event.offsetY |
|
|
|
const h = (event.currentTarget as HTMLDivElement).offsetHeight |
|
|
|
if (y < h / 3) { |
|
|
|
if (y < h / 3 && !opts.sort) { |
|
|
|
status.value = ENiuTreeStatus.DragUp |
|
|
|
} else if (y <= (h * 2) / 3 && y >= h / 3 && props.data.children) { |
|
|
|
status.value = ENiuTreeStatus.DragIn |
|
|
|
} else if (y > (h * 2) / 3) { |
|
|
|
} else if (y > (h * 2) / 3 && !opts.sort) { |
|
|
|
status.value = ENiuTreeStatus.DragDown |
|
|
|
} else { |
|
|
|
status.value = undefined |
|
|
|