diff --git a/examples/Interaction/index.tsx b/examples/Interaction/index.tsx new file mode 100644 index 00000000..5c8b3330 --- /dev/null +++ b/examples/Interaction/index.tsx @@ -0,0 +1,172 @@ +import RevueFlow, { + addEdge, + MiniMap, + Controls, + Elements, + Node, + FlowElement, + Connection, + Edge, + PanOnScrollMode, + FlowTransform +} from '../../src'; +import { defineComponent, ref } from 'vue'; + +const initialElements: Elements = [ + { id: '1', type: 'input', data: { label: 'Node 1' }, position: { x: 250, y: 5 } }, + { id: '2', data: { label: 'Node 2' }, position: { x: 100, y: 100 } }, + { id: '3', data: { label: 'Node 3' }, position: { x: 400, y: 100 } }, + { id: '4', data: { label: 'Node 4' }, position: { x: 400, y: 200 } }, + { id: 'e1-2', source: '1', target: '2', animated: true }, + { id: 'e1-3', source: '1', target: '3' } +] as Elements; + +const onNodeDragStart = (_: MouseEvent, node: Node) => console.log('drag start', node); +const onNodeDragStop = (_: MouseEvent, node: Node) => console.log('drag stop', node); +const onElementClick = (_: MouseEvent, element: FlowElement) => console.log('click', element); +const onPaneClick = (event: MouseEvent) => console.log('onPaneClick', event); +const onPaneScroll = (event?: WheelEvent) => console.log('onPaneScroll', event); +const onPaneContextMenu = (event: MouseEvent) => console.log('onPaneContextMenu', event); +const onMoveEnd = (flowTranasform?: FlowTransform) => console.log('onMoveEnd', flowTranasform); + +const InteractionFlow = defineComponent({ + setup() { + const elements = ref(initialElements); + const onConnect = (params: Connection | Edge) => (elements.value = addEdge(params, elements.value)); + + const isSelectable = ref(false); + const isDraggable = ref(false); + const isConnectable = ref(false); + const zoomOnScroll = ref(false); + const zoomOnPinch = ref(false); + const panOnScroll = ref(false); + const panOnScrollMode = ref(PanOnScrollMode.Free); + const zoomOnDoubleClick = ref(false); + const paneMoveable = ref(true); + const captureZoomClick = ref(false); + const captureZoomScroll = ref(false); + const captureElementClick = ref(false); + + return () => ( + + + + +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ ); + } +}); + +export default InteractionFlow; diff --git a/examples/router.ts b/examples/router.ts index 809ace7e..168dcc43 100644 --- a/examples/router.ts +++ b/examples/router.ts @@ -40,6 +40,10 @@ export const routes: RouterOptions['routes'] = [ { path: '/hidden', component: () => import('./Hidden') + }, + { + path: '/interaction', + component: () => import('./Interaction') } ];