chore(resize-rotate-node): update README.md
This commit is contained in:
@@ -1,82 +1,84 @@
|
|||||||
# Vue Flow Pathfinding Edge 🧲
|
# Vue Flow Resizable Rotatable Node
|
||||||
|
|
||||||

|
### Custom Node that can be resized and rotated
|
||||||
[](https://david-dm.org/bcakmakoglu/vue-flow-pathfinding-edge)
|
|
||||||
[](https://david-dm.org/bcakmakoglu/vue-flow-pathfinding-edge?type=dev)
|
|
||||||

|
|
||||||

|
|
||||||

|
|
||||||
|
|
||||||
### **Custom Edge that avoids crossing other Nodes**
|
|
||||||
|
|
||||||
Check the [documentation](https://vueflow.dev/docs/addons/pathfinding) for more info on how to use this custom edge.
|
|
||||||
|
|
||||||
## 🛠 Setup
|
## 🛠 Setup
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# install
|
# install
|
||||||
$ yarn add @braks/vue-flow-pathfinding-edge
|
$ yarn add @braks/vue-flow-resize-rotate-node
|
||||||
|
|
||||||
# or
|
# or
|
||||||
$ npm i --save @braks/vue-flow-pathfinding-edge
|
$ npm i --save @braks/vue-flow-resize-rotate-node
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🎮 Quickstart
|
## 🎮 Quickstart
|
||||||
|
|
||||||
```vue
|
```vue
|
||||||
<script lang="ts" setup>
|
|
||||||
import {
|
<script setup>
|
||||||
VueFlow,
|
import { VueFlow } from '@braks/vue-flow'
|
||||||
Elements,
|
import { ResizeRotateNode } from '@braks/vue-flow-resize-rotate-node'
|
||||||
useVueFlow
|
|
||||||
} from '@braks/vue-flow'
|
|
||||||
import { PathFindingEdge } from '@braks/vue-flow-pathfinding-edge'
|
|
||||||
import initialElements from './initial-elements'
|
import initialElements from './initial-elements'
|
||||||
|
|
||||||
const elements = ref<Elements>(initialElements)
|
const elements = ref(initialElements)
|
||||||
|
|
||||||
// create a new context so we can fetch nodes
|
|
||||||
const { getNodes } = useVueFlow({
|
|
||||||
modelValue: elements.value
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div style="height: 300px">
|
<div style="height: 300px">
|
||||||
<VueFlow>
|
<VueFlow v-model="elements">
|
||||||
<template #edge-pathFinding="props">
|
<template #node-resize-rotate="props">
|
||||||
<PathFindingEdge v-bind="props" :nodes="getNodes" />
|
<ResizeRotateNode v-bind="props" />
|
||||||
</template>
|
</template>
|
||||||
</VueFlow>
|
</VueFlow>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
```
|
```
|
||||||
|
|
||||||
```typescript
|
```js
|
||||||
// initial-elements.ts
|
// initial-elements.js
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
id: '1',
|
id: '1',
|
||||||
label: 'Node 1',
|
label: 'Node 1',
|
||||||
|
type: 'resize-rotate',
|
||||||
|
targetPosition: 'left',
|
||||||
|
sourcePosition: 'right',
|
||||||
position: {
|
position: {
|
||||||
x: 430,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
},
|
},
|
||||||
|
data: {
|
||||||
|
// additional styles for the node
|
||||||
|
// cannot use the regular style tag as those apply to the node wrapper
|
||||||
|
style: {
|
||||||
|
background: 'rgb(255, 0, 114) none repeat scroll 0% 0%',
|
||||||
|
padding: '20px',
|
||||||
|
borderRadius: '20px',
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '2',
|
id: '2',
|
||||||
label: 'Node 2',
|
label: 'Node 2',
|
||||||
|
type: 'resize-rotate',
|
||||||
|
targetPosition: 'left',
|
||||||
position: {
|
position: {
|
||||||
x: 230,
|
x: 330,
|
||||||
y: 90,
|
y: 50,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
style: {
|
||||||
|
background: 'rgb(50, 188, 188) none repeat scroll 0% 0%',
|
||||||
|
padding: '20px',
|
||||||
|
borderRadius: '20px',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'e12',
|
id: 'e1-2',
|
||||||
source: '1',
|
source: '1',
|
||||||
target: '2',
|
target: '2',
|
||||||
label: 'Smart Edge',
|
type: 'smoothstep',
|
||||||
style: { stroke: 'red' },
|
|
||||||
type: 'pathFinding'
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user