-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
edge.vue
61 lines (55 loc) · 1.61 KB
/
edge.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<script setup lang="ts">
import { PropType } from "vue"
import { useEdgeConfig } from "../composables/config"
import { Position } from "../common/types"
import { EdgeState } from "../composables/state"
import VEdgeLine from "./line.vue"
import VEdgeCurved from "./edge-curved.vue"
defineProps({
id: {
type: String,
required: true,
},
state: {
type: Object as PropType<EdgeState>,
required: true,
},
sourcePos: {
type: Object as PropType<Position>,
required: false,
default: undefined,
},
targetPos: {
type: Object as PropType<Position>,
required: false,
default: undefined,
},
})
const config = useEdgeConfig()
defineExpose({ config })
</script>
<template>
<v-edge-line
v-if="config.type == 'straight' || !state.curve"
v-bind="state.position"
:class="{ selectable: state.selectable, hover: state.hovered, selected: state.selected }"
:config="state.line.stroke"
:marker-start="state.sourceMarkerId ? `url(#${state.sourceMarkerId})` : undefined"
:marker-end="state.targetMarkerId ? `url(#${state.targetMarkerId})` : undefined"
/>
<v-edge-curved
v-else
:class="{ selectable: state.selectable, hover: state.hovered, selected: state.selected }"
:state="state"
:config="state.line.stroke"
:marker-start="state.sourceMarkerId ? `url(#${state.sourceMarkerId})` : undefined"
:marker-end="state.targetMarkerId ? `url(#${state.targetMarkerId})` : undefined"
/>
</template>
<style lang="scss" scoped>
$transition: 0.1s linear;
:where(.v-line) {
transition: stroke $transition, stroke-width $transition;
pointer-events: none;
}
</style>