Skip to content

Commit 0515c07

Browse files
committed
chore(vite-examples): update basic example
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
1 parent 8e7e299 commit 0515c07

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

examples/vite/src/Basic/Basic.vue

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts" setup>
22
import type { Elements } from '@vue-flow/core'
3-
import { VueFlow, isNode, useVueFlow } from '@vue-flow/core'
3+
import { Panel, PanelPosition, VueFlow, isNode, useVueFlow } from '@vue-flow/core'
44
55
import { Background } from '@vue-flow/background'
66
import { Controls } from '@vue-flow/controls'
@@ -15,13 +15,19 @@ const elements = ref<Elements>([
1515
{ id: 'e1-3', source: '1', target: '3' },
1616
])
1717
18-
const { onConnect, addEdges, setTransform, toObject } = useVueFlow({
18+
const keyCode = ref('Shift')
19+
20+
const { selectionKeyCode, onConnect, addEdges, setTransform, toObject } = useVueFlow({
1921
minZoom: 0.2,
2022
maxZoom: 4,
2123
})
2224
2325
onConnect((params) => addEdges([params]))
2426
27+
function changeKeyCode() {
28+
keyCode.value = keyCode.value === 'Shift' ? 'Meta' : 'Shift'
29+
}
30+
2531
function updatePos() {
2632
return elements.value.forEach((el) => {
2733
if (isNode(el)) {
@@ -45,15 +51,16 @@ function toggleclass() {
4551
</script>
4652

4753
<template>
48-
<VueFlow v-model="elements" fit-view-on-init class="vue-flow-basic-example">
54+
<VueFlow v-model="elements" :selection-key-code="keyCode" fit-view-on-init class="vue-flow-basic-example">
4955
<Background />
5056
<MiniMap />
5157
<Controls />
52-
<div style="position: absolute; right: 10px; top: 10px; z-index: 4">
53-
<button style="margin-right: 5px" @click="resetTransform">reset transform</button>
54-
<button style="margin-right: 5px" @click="updatePos">change pos</button>
55-
<button style="margin-right: 5px" @click="toggleclass">toggle class</button>
58+
<Panel :position="PanelPosition.TopRight" style="display: flex; gap: 5px">
59+
{{ selectionKeyCode }}
60+
<button @click="changeKeyCode">change keyCode</button>
61+
<button @click="updatePos">change pos</button>
62+
<button @click="toggleclass">toggle class</button>
5663
<button @click="logToObject">toObject</button>
57-
</div>
64+
</Panel>
5865
</VueFlow>
5966
</template>

0 commit comments

Comments
 (0)