docs: fix node pos on resize
This commit is contained in:
@@ -64,6 +64,8 @@ const { dimensions, instance, onPaneReady, getNodes, getNode, getEdge, updateEdg
|
|||||||
|
|
||||||
const init = ref(false)
|
const init = ref(false)
|
||||||
const edgeId = ref('eintro-documentation')
|
const edgeId = ref('eintro-documentation')
|
||||||
|
const el = templateRef<HTMLDivElement>('el', null)
|
||||||
|
|
||||||
onPaneReady(({ fitView }) => {
|
onPaneReady(({ fitView }) => {
|
||||||
fitView({
|
fitView({
|
||||||
duration: 1500,
|
duration: 1500,
|
||||||
@@ -78,7 +80,10 @@ onPaneReady(({ fitView }) => {
|
|||||||
node.position = { x: 0, y: 0 }
|
node.position = { x: 0, y: 0 }
|
||||||
break
|
break
|
||||||
case 'examples':
|
case 'examples':
|
||||||
node.position = { x: mainNode.dimensions.width / 2 - node.dimensions.width / 2, y: mainNode.dimensions.height * 1.5 }
|
node.position = {
|
||||||
|
x: mainNode.dimensions.width / 2 - node.dimensions.width / 2,
|
||||||
|
y: mainNode.dimensions.height * 1.5,
|
||||||
|
}
|
||||||
break
|
break
|
||||||
case 'documentation':
|
case 'documentation':
|
||||||
node.position = {
|
node.position = {
|
||||||
@@ -105,6 +110,7 @@ onPaneReady(({ fitView }) => {
|
|||||||
node.position = { x: -node.dimensions.width / 2, y: mainNode.dimensions.height * 1.5 }
|
node.position = { x: -node.dimensions.width / 2, y: mainNode.dimensions.height * 1.5 }
|
||||||
break
|
break
|
||||||
case 'documentation':
|
case 'documentation':
|
||||||
|
console.log(mainNode.dimensions.width, node.dimensions.width)
|
||||||
node.position = {
|
node.position = {
|
||||||
x: mainNode.dimensions.width - node.dimensions.width / 2,
|
x: mainNode.dimensions.width - node.dimensions.width / 2,
|
||||||
y: mainNode.dimensions.height * 1.5,
|
y: mainNode.dimensions.height * 1.5,
|
||||||
@@ -129,11 +135,11 @@ onPaneReady(({ fitView }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
watch([breakpoints.sm, breakpoints.md, breakpoints.lg, breakpoints.xl, breakpoints['2xl']], setNodes, { immediate: true })
|
useResizeObserver(el, setNodes)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="h-[90vh] md:h-[75vh]">
|
<div ref="el" class="h-[90vh] md:h-[75vh]">
|
||||||
<VueFlow class="dark:bg-black bg-white transition-colors duration-200 ease-in-out">
|
<VueFlow class="dark:bg-black bg-white transition-colors duration-200 ease-in-out">
|
||||||
<template #node-box="props">
|
<template #node-box="props">
|
||||||
<template v-if="props.id === 'intro'">
|
<template v-if="props.id === 'intro'">
|
||||||
|
|||||||
Reference in New Issue
Block a user