feat(nodes): implement useDrag in NodesSelection.vue
This commit is contained in:
@@ -1,22 +1,21 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useVueFlow, useDrag } from '../../composables'
|
import { useDrag, useVueFlow } from '../../composables'
|
||||||
import { getRectOfNodes } from '../../utils'
|
import { getRectOfNodes } from '../../utils'
|
||||||
|
|
||||||
const { emits, setState, viewport, getSelectedNodes, snapToGrid, snapGrid, updateNodePosition, noPanClassName } = $(useVueFlow())
|
const { emits, setState, viewport, getSelectedNodes, snapToGrid, snapGrid, noPanClassName } = $(useVueFlow())
|
||||||
|
|
||||||
const el = ref()
|
const el = ref()
|
||||||
|
|
||||||
useDrag({
|
useDrag({
|
||||||
el,
|
el,
|
||||||
onStart(event) {
|
onStart(event, node, nodes) {
|
||||||
emits.selectionDragStart({ event: event.sourceEvent, nodes: getSelectedNodes })
|
emits.selectionDragStart({ event, node, nodes })
|
||||||
},
|
},
|
||||||
onDrag(event, { dx, dy }) {
|
onDrag(event, node, nodes) {
|
||||||
updateNodePosition({ diff: { x: dx, y: dy } })
|
emits.selectionDrag({ event, node, nodes })
|
||||||
emits.selectionDrag({ event: event.sourceEvent, nodes: getSelectedNodes })
|
|
||||||
},
|
},
|
||||||
onStop(event) {
|
onStop(event, node, nodes) {
|
||||||
emits.selectionDragStop({ event: event.sourceEvent, nodes: getSelectedNodes })
|
emits.selectionDragStop({ event, node, nodes })
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import type { DefaultEdgeOptions, Edge, GraphEdge } from './edge'
|
|||||||
import type { CoordinateExtent, GraphNode, Node } from './node'
|
import type { CoordinateExtent, GraphNode, Node } from './node'
|
||||||
import type { D3Selection, D3Zoom, D3ZoomHandler, KeyCode, PanOnScrollMode, Viewport } from './zoom'
|
import type { D3Selection, D3Zoom, D3ZoomHandler, KeyCode, PanOnScrollMode, Viewport } from './zoom'
|
||||||
import type { FlowHooks, FlowHooksEmit, FlowHooksOn } from './hooks'
|
import type { FlowHooks, FlowHooksEmit, FlowHooksOn } from './hooks'
|
||||||
import type { EdgeChange, NodeChange, NodeDragItem } from "./changes";
|
import type { EdgeChange, NodeChange, NodeDragItem } from './changes'
|
||||||
import type { HandleType, StartHandle } from './handle'
|
import type { HandleType, StartHandle } from './handle'
|
||||||
|
|
||||||
export interface UpdateNodeDimensionsParams {
|
export interface UpdateNodeDimensionsParams {
|
||||||
|
|||||||
Reference in New Issue
Block a user