feat(svelte) added nodedrag events

This commit is contained in:
Peter
2023-09-20 12:05:16 +02:00
parent 3eb9c12c20
commit 3c3239afd8
6 changed files with 38 additions and 4 deletions
@@ -1,22 +1,28 @@
import { get } from 'svelte/store';
import { XYDrag } from '@xyflow/system';
import { XYDrag, type OnDrag } from '@xyflow/system';
import type { SvelteFlowStore } from '$lib/store/types';
type UseDragParams = {
export type UseDragParams = {
store: SvelteFlowStore;
disabled?: boolean;
noDragClass?: string;
handleSelector?: string;
nodeId?: string;
isSelectable?: boolean;
onDrag?: OnDrag;
onDragStart?: OnDrag;
onDragStop?: OnDrag;
};
export default function drag(domNode: Element, params: UseDragParams) {
const { store, onDrag, onDragStart, onDragStop } = params;
const dragInstance = XYDrag({
domNode,
onDrag,
onDragStart,
onDragStop,
getStoreItems: () => {
const { store } = params;
const snapGrid = get(store.snapGrid);
return {