refactor(controls): remove reactivity transform vars

Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
braks
2023-04-03 08:53:33 +02:00
committed by Braks
parent d888b0c1ab
commit e9ff4cca9d
+8 -5
View File
@@ -1,6 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { Panel, useVueFlow } from '@vue-flow/core' import { Panel, PanelPosition, useVueFlow } from '@vue-flow/core'
import type { PanelPosition } from '@vue-flow/core'
import type { ControlProps } from './types' import type { ControlProps } from './types'
import ControlButton from './ControlButton.vue' import ControlButton from './ControlButton.vue'
import PlusIcon from './icons/plus.svg' import PlusIcon from './icons/plus.svg'
@@ -14,7 +13,7 @@ const {
showFitView = true, showFitView = true,
showInteractive = true, showInteractive = true,
fitViewParams, fitViewParams,
position = 'bottom-left' as PanelPosition, position = PanelPosition.BottomLeft,
} = defineProps<ControlProps>() } = defineProps<ControlProps>()
const emit = defineEmits<{ const emit = defineEmits<{
@@ -24,27 +23,31 @@ const emit = defineEmits<{
(event: 'interactionChange', active: boolean): void (event: 'interactionChange', active: boolean): void
}>() }>()
const { nodesDraggable, nodesConnectable, elementsSelectable, setInteractive, zoomIn, zoomOut, fitView } = $(useVueFlow()) const { nodesDraggable, nodesConnectable, elementsSelectable, setInteractive, zoomIn, zoomOut, fitView } = useVueFlow()
const isInteractive = computed(() => nodesDraggable && nodesConnectable && elementsSelectable) const isInteractive = computed(() => nodesDraggable.value && nodesConnectable.value && elementsSelectable.value)
function onZoomInHandler() { function onZoomInHandler() {
zoomIn() zoomIn()
emit('zoomIn') emit('zoomIn')
} }
function onZoomOutHandler() { function onZoomOutHandler() {
zoomOut() zoomOut()
emit('zoomOut') emit('zoomOut')
} }
function onFitViewHandler() { function onFitViewHandler() {
fitView(fitViewParams) fitView(fitViewParams)
emit('fitView') emit('fitView')
} }
function onInteractiveChangeHandler() { function onInteractiveChangeHandler() {
setInteractive(!isInteractive.value) setInteractive(!isInteractive.value)
emit('interactionChange', !isInteractive.value) emit('interactionChange', !isInteractive.value)
} }
</script> </script>