-
-
Notifications
You must be signed in to change notification settings - Fork 209
/
NodeResizer.vue
65 lines (58 loc) 路 1.81 KB
/
NodeResizer.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
62
63
64
65
<script lang="ts" setup>
// todo: add plugin to emit resize events via vue flow store; requires plugin API to be added to core
import ResizeControl from './ResizeControl.vue'
import type { ControlLinePosition, ControlPosition, NodeResizerProps, OnResize, OnResizeStart } from './types'
import { ResizeControlVariant } from './types'
withDefaults(defineProps<NodeResizerProps>(), {
isVisible: true,
})
const emits = defineEmits<{
(event: 'resizeStart', resizeEvent: OnResizeStart): void
(event: 'resize', resizeEvent: OnResize): void
(event: 'resizeEnd', resizeEvent: OnResizeStart): void
}>()
const handleControls: ControlPosition[] = ['top-left', 'top-right', 'bottom-left', 'bottom-right']
const lineControls: ControlLinePosition[] = ['top', 'right', 'bottom', 'left']
</script>
<script lang="ts">
export default {
name: 'NodeResizer',
compatConfig: { MODE: 3 },
inheritAttrs: false,
}
</script>
<template>
<ResizeControl
v-for="c of lineControls"
:key="c"
:class="lineClassName"
:style="lineStyle"
:node-id="nodeId"
:position="c"
:variant="ResizeControlVariant.Line"
:keep-aspect-ratio="keepAspectRatio"
:color="color"
:min-width="minWidth"
:min-height="minHeight"
:should-resize="shouldResize"
@resize-start="emits('resizeStart', $event)"
@resize="emits('resize', $event)"
@resize-end="emits('resizeEnd', $event)"
/>
<ResizeControl
v-for="c of handleControls"
:key="c"
:class="lineClassName"
:style="lineStyle"
:node-id="nodeId"
:position="c"
:color="color"
:min-width="minWidth"
:min-height="minHeight"
:should-resize="shouldResize"
:keep-aspect-ratio="keepAspectRatio"
@resize-start="emits('resizeStart', $event)"
@resize="emits('resize', $event)"
@resize-end="emits('resizeEnd', $event)"
/>
</template>