返回 slidev
VDragArrow.vue
根目录 / packages / client / builtin / VDragArrow.vue
1 <script setup lang="ts">
2 import type { DragElementMarkdownSource } from '../composables/useDragElements'
3 import { computed, onMounted, onUnmounted } from 'vue'
4 import { useDragElement } from '../composables/useDragElements'
5 import Arrow from './Arrow.vue'
6
7 const props = defineProps<{
8 pos?: string
9 markdownSource?: DragElementMarkdownSource
10 width?: number | string
11 color?: string
12 twoWay?: boolean
13 }>()
14
15 const { dragId, mounted, unmounted, startDragging, stopDragging, x0, y0, width, height } = useDragElement(null, props.pos ?? '100,100,300,300', props.markdownSource, true)
16
17 onMounted(mounted)
18 onUnmounted(unmounted)
19
20 const x1 = computed(() => x0.value - width.value / 2)
21 const y1 = computed(() => y0.value - height.value / 2)
22 const x2 = computed(() => x0.value + width.value / 2)
23 const y2 = computed(() => y0.value + height.value / 2)
24 </script>
25
26 <template>
27 <Arrow
28 :x1 :y1 :x2 :y2
29 :data-drag-id="dragId"
30 :width="props.width"
31 :color="props.color"
32 :two-way="props.twoWay"
33 @dblclick="startDragging"
34 @click-outside="stopDragging"
35 />
36 </template>
37
37 lines Plain Text