feat(docs): disable pan on mobile

This commit is contained in:
Braks
2022-04-04 21:42:48 +02:00
parent 3c48913090
commit 59ac64564a
2 changed files with 16 additions and 4 deletions
+12 -2
View File
@@ -1,17 +1,19 @@
<script lang="ts" setup>
import { ConnectionMode, useVueFlow, VueFlow, Background, Controls } from '@braks/vue-flow'
import { breakpointsTailwind } from '@vueuse/core'
const breakpoints = useBreakpoints(breakpointsTailwind)
const emit = defineEmits(['pane'])
const nodeClasses = ['!normal-case font-semibold !text-white', '!border-1', 'shadow-md'].join(' ')
const childClasses = `${nodeClasses} !bg-green-500/70 !border-white`
const { onPaneReady } = useVueFlow({
const { onPaneReady, panOnDrag } = useVueFlow({
fitViewOnInit: true,
connectionMode: ConnectionMode.Loose,
zoomOnScroll: false,
preventScrolling: false,
panOnDrag: false,
translateExtent: [
[-500, -100],
[600, 500],
@@ -43,6 +45,14 @@ const { onPaneReady } = useVueFlow({
],
})
watch(
[breakpoints.sm, breakpoints.md, breakpoints.lg, breakpoints.xl, breakpoints['2xl']],
() => {
panOnDrag.value = !breakpoints.isSmaller('md')
},
{ immediate: true },
)
onPaneReady((i) => emit('pane', i))
</script>
<template>