feat(docs): disable pan on mobile
This commit is contained in:
@@ -1,17 +1,19 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ConnectionMode, useVueFlow, VueFlow, Background, Controls } from '@braks/vue-flow'
|
import { ConnectionMode, useVueFlow, VueFlow, Background, Controls } from '@braks/vue-flow'
|
||||||
|
import { breakpointsTailwind } from '@vueuse/core'
|
||||||
|
|
||||||
|
const breakpoints = useBreakpoints(breakpointsTailwind)
|
||||||
|
|
||||||
const emit = defineEmits(['pane'])
|
const emit = defineEmits(['pane'])
|
||||||
|
|
||||||
const nodeClasses = ['!normal-case font-semibold !text-white', '!border-1', 'shadow-md'].join(' ')
|
const nodeClasses = ['!normal-case font-semibold !text-white', '!border-1', 'shadow-md'].join(' ')
|
||||||
const childClasses = `${nodeClasses} !bg-green-500/70 !border-white`
|
const childClasses = `${nodeClasses} !bg-green-500/70 !border-white`
|
||||||
|
|
||||||
const { onPaneReady } = useVueFlow({
|
const { onPaneReady, panOnDrag } = useVueFlow({
|
||||||
fitViewOnInit: true,
|
fitViewOnInit: true,
|
||||||
connectionMode: ConnectionMode.Loose,
|
connectionMode: ConnectionMode.Loose,
|
||||||
zoomOnScroll: false,
|
zoomOnScroll: false,
|
||||||
preventScrolling: false,
|
preventScrolling: false,
|
||||||
panOnDrag: false,
|
|
||||||
translateExtent: [
|
translateExtent: [
|
||||||
[-500, -100],
|
[-500, -100],
|
||||||
[600, 500],
|
[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))
|
onPaneReady((i) => emit('pane', i))
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ type Colors = {
|
|||||||
|
|
||||||
const emit = defineEmits(['pane'])
|
const emit = defineEmits(['pane'])
|
||||||
|
|
||||||
const { onPaneReady, getNode } = useVueFlow({
|
const { onPaneReady, getNode, panOnDrag } = useVueFlow({
|
||||||
id: 'rgb-flow',
|
id: 'rgb-flow',
|
||||||
nodes: [
|
nodes: [
|
||||||
{ id: '1', type: 'rgb', data: { color: 'g' }, position: { x: -25, y: 0 } },
|
{ id: '1', type: 'rgb', data: { color: 'g' }, position: { x: -25, y: 0 } },
|
||||||
@@ -48,9 +48,11 @@ const color = ref<Colors>({
|
|||||||
watch(
|
watch(
|
||||||
[breakpoints.sm, breakpoints.md, breakpoints.lg, breakpoints.xl, breakpoints['2xl']],
|
[breakpoints.sm, breakpoints.md, breakpoints.lg, breakpoints.xl, breakpoints['2xl']],
|
||||||
() => {
|
() => {
|
||||||
if (breakpoints.isSmaller('md')) {
|
const mobile = breakpoints.isSmaller('md')
|
||||||
|
if (mobile) {
|
||||||
getNode.value('4')!.position = { x: 300, y: -25 }
|
getNode.value('4')!.position = { x: 300, y: -25 }
|
||||||
}
|
}
|
||||||
|
panOnDrag.value = !mobile
|
||||||
},
|
},
|
||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user